Skip to content

Commit 0d31903

Browse files
author
Philipp Ullmann
committed
Fixes #55: Fixed named paramter order issue
1 parent 9f7d099 commit 0d31903

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

src/yesql/generate.clj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@
6161
[(first (:? args)) (update-in args [:?] rest)]
6262
[(get args (keyword token)) args])]
6363
[(str query (args-to-placeholders arg))
64-
(if (in-list-parameter? arg)
65-
(concat parameters arg)
66-
(conj parameters arg))
64+
(vec (if (in-list-parameter? arg)
65+
(concat parameters arg)
66+
(conj parameters arg)))
6767
new-args])))
6868
["" [] initial-args]
6969
tokens)]

test/yesql/generate_test.clj

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,12 @@
7676
"SELECT age FROM users WHERE country = :country AND name IN (:names)"
7777
{:country "gb"
7878
:names []}
79-
=> ["SELECT age FROM users WHERE country = ? AND name IN ()" "gb"])
79+
=> ["SELECT age FROM users WHERE country = ? AND name IN ()" "gb"]
80+
81+
"SELECT * FROM users WHERE group_ids IN(:group_ids) AND parent_id = :parent_id"
82+
{:group_ids [1 2]
83+
:parent_id 3}
84+
=> ["SELECT * FROM users WHERE group_ids IN(?,?) AND parent_id = ?" 1 2 3])
8085

8186
;;; Incorrect parameters.
8287
(expect AssertionError

0 commit comments

Comments
 (0)