diff --git a/README.md b/README.md index 1f318f9..ad014db 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Everything is built on top of maps representing SQL queries: ```clj (sql/format sqlmap) -=> ["SELECT a, b, c FROM foo WHERE (f.a = ?)" ["baz"]] +=> ["SELECT a, b, c FROM foo WHERE (f.a = ?)" "baz"] ``` There are helper functions to build SQL maps. They compose together nicely: @@ -59,7 +59,7 @@ To add to clauses instead of replacing them, use `merge-select`, `merge-where`, (-> sqlmap (merge-select :d :e) (merge-where [:> :b 10]))) -=> ["SELECT a, b, c, d, e FROM foo WHERE ((f.a = ?) AND (b > 10))" ["baz"]] +=> ["SELECT a, b, c, d, e FROM foo WHERE ((f.a = ?) AND (b > 10))" "baz"] ``` Queries can be nested: @@ -104,7 +104,7 @@ Here's a big, complicated query. (Note that Honey SQL makes no attempt to verify (sql/format *1) => ["SELECT DISTINCT f.*, b.baz, c.quux, NOW(), @x := 10 FROM foo AS f, baz AS b LEFT JOIN clod AS c ON (f.a = c.d) JOIN draq ON (f.b = draq.x) WHERE (((f.a = ?) AND (b.baz != ?)) OR (f.e IN (1, 2, 3)) OR f.e BETWEEN 10 AND 20) GROUP BY f.a HAVING (0 < f.e) ORDER BY b.baz DESC, c.quux LIMIT 50 OFFSET 10" - ["bort" "gabba"]] + "bort" "gabba"] ;; Printable and readable (= *2 (read-string (pr-str *2))) diff --git a/src/honeysql/format.clj b/src/honeysql/format.clj index 6ffb9c6..a05945c 100644 --- a/src/honeysql/format.clj +++ b/src/honeysql/format.clj @@ -50,7 +50,7 @@ (binding [*params* (atom [])] (let [sql-str (to-sql sql-map)] (if (seq @*params*) - [sql-str @*params*] + (into [sql-str] @*params*) [sql-str])))) (defprotocol ToSql diff --git a/test/honeysql/core_test.clj b/test/honeysql/core_test.clj index 955018f..7a95326 100644 --- a/test/honeysql/core_test.clj +++ b/test/honeysql/core_test.clj @@ -23,6 +23,6 @@ (testing "sqlmap formats correctly" (is (= (format sqlmap) ["SELECT DISTINCT f.*, b.baz, c.quux, NOW(), @x := 10 FROM foo AS f, baz AS b LEFT JOIN clod AS c ON (f.a = c.d) JOIN draq ON (f.b = draq.x) WHERE (((f.a = ?) AND (b.baz != ?)) OR (f.e IN (1, 2, 3)) OR f.e BETWEEN 10 AND 20) GROUP BY f.a HAVING (0 < f.e) ORDER BY b.baz DESC, c.quux LIMIT 50 OFFSET 10" - ["bort" "gabba"]]))) + "bort" "gabba"]))) (testing "sqlmap prints and reads correctly" (is (= sqlmap (read-string (pr-str sqlmap))))))) \ No newline at end of file