From 84a80f40f5c888f8452d07bd15f3b5fba49d3963 Mon Sep 17 00:00:00 2001 From: Paul Date: Sun, 15 Jan 2017 11:27:06 -0800 Subject: [PATCH] Fix SQL quoting when calling honeysql/format (#175). r=rnewman --- src/common/datomish/query.cljc | 4 ++-- test/datomish/test/query.cljc | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/common/datomish/query.cljc b/src/common/datomish/query.cljc index bddc50b6..c2966607 100644 --- a/src/common/datomish/query.cljc +++ b/src/common/datomish/query.cljc @@ -110,7 +110,7 @@ (-> context context->sql-clause - (sql/format args :quoting sql-quoting-style))) + (sql/format :params args :quoting sql-quoting-style))) (defn- validate-with [with] (when-not (or (nil? with) @@ -215,7 +215,7 @@ [context find args] (-> (find->sql-clause context find) - (sql/format args :quoting sql-quoting-style))) + (sql/format :params args :quoting sql-quoting-style))) (defn parse "Parse a Datalog query array into a structured `find` expression." diff --git a/test/datomish/test/query.cljc b/test/datomish/test/query.cljc index 5c6f2ba0..9a04082f 100644 --- a/test/datomish/test/query.cljc +++ b/test/datomish/test/query.cljc @@ -925,3 +925,15 @@ {:select ['x] :from [:def]})} :foo])}))))) + +(deftest-db test-sql-quoting conn + (testing "ansi sql quoting applied when there are no inputs" + (is (= ["SELECT DISTINCT \"datoms0\".\"e\" AS \"order\" FROM \"datoms\" \"datoms0\" WHERE (\"datoms0\".\"a\" = \"order\") "] + (datomish.query/find->sql-string + (conn->context conn) + (datomish.query/parse + '[:find ?order + :in $ + :where + [?order :item/order]]) + nil)))))