data reader & test for param
This commit is contained in:
parent
51d0d220a0
commit
e0c190b50e
2 changed files with 10 additions and 8 deletions
|
|
@ -1,2 +1,3 @@
|
||||||
{sql/call honeysql.types/read-sql-call
|
{sql/call honeysql.types/read-sql-call
|
||||||
sql/raw honeysql.types/read-sql-raw}
|
sql/raw honeysql.types/read-sql-raw
|
||||||
|
sql/param honeysql.types/read-sql-param}
|
||||||
|
|
@ -15,9 +15,9 @@
|
||||||
(join [[:clod :c] [:= :f.a :c.d] :left]
|
(join [[:clod :c] [:= :f.a :c.d] :left]
|
||||||
[:draq [:= :f.b :draq.x]])
|
[:draq [:= :f.b :draq.x]])
|
||||||
(where [:or
|
(where [:or
|
||||||
[:and [:= :f.a "bort"] [:not= :b.baz "gabba"]]
|
[:and [:= :f.a "bort"] [:not= :b.baz (sql/param :param1)]]
|
||||||
[:< 1 2 3]
|
[:< 1 2 3]
|
||||||
[:in :f.e [1 2 3]]
|
[:in :f.e [1 (sql/param :param2) 3]]
|
||||||
[:between :f.e 10 20]])
|
[:between :f.e 10 20]])
|
||||||
;;(merge-where [:not= nil :b.bla])
|
;;(merge-where [:not= nil :b.bla])
|
||||||
(group :f.a)
|
(group :f.a)
|
||||||
|
|
@ -33,9 +33,9 @@
|
||||||
:join [[[:clod :c] [:= :f.a :c.d] :left]
|
:join [[[:clod :c] [:= :f.a :c.d] :left]
|
||||||
[:draq [:= :f.b :draq.x]]]
|
[:draq [:= :f.b :draq.x]]]
|
||||||
:where [:or
|
:where [:or
|
||||||
[:and [:= :f.a "bort"] [:not= :b.baz "gabba"]]
|
[:and [:= :f.a "bort"] [:not= :b.baz (sql/param :param1)]]
|
||||||
[:< 1 2 3]
|
[:< 1 2 3]
|
||||||
[:in :f.e [1 2 3]]
|
[:in :f.e [1 (sql/param :param2) 3]]
|
||||||
[:between :f.e 10 20]]
|
[:between :f.e 10 20]]
|
||||||
;;:merge-where [:not= nil :b.bla]
|
;;:merge-where [:not= nil :b.bla]
|
||||||
:group-by :f.a
|
:group-by :f.a
|
||||||
|
|
@ -48,7 +48,8 @@
|
||||||
(testing "Various construction methods are consistent"
|
(testing "Various construction methods are consistent"
|
||||||
(is (= m1 m3)))
|
(is (= m1 m3)))
|
||||||
(testing "SQL data formats correctly"
|
(testing "SQL data formats correctly"
|
||||||
(is (= (sql/format m1)
|
(is (= (sql/format m1 {:param1 "gabba" :param2 2})
|
||||||
["SELECT DISTINCT f.*, b.baz, c.quux, b.bla AS \"bla-bla\", 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 (1 < 2 AND 2 < 3) 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"])))
|
["SELECT DISTINCT f.*, b.baz, c.quux, b.bla AS \"bla-bla\", 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 (1 < 2 AND 2 < 3) OR (f.e IN (1, ?, 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" 2])))
|
||||||
(testing "SQL data prints and reads correctly"
|
(testing "SQL data prints and reads correctly"
|
||||||
(is (= m1 (read-string (pr-str m1)))))))
|
(is (= m1 (read-string (pr-str m1)))))))
|
||||||
Loading…
Reference in a new issue