Skip to content

Commit

Permalink
fix parameter mismatch validation (issue #23)
Browse files Browse the repository at this point in the history
  • Loading branch information
csummers committed Feb 24, 2016
1 parent 1b1d469 commit 5fc2139
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion hugsql-core/src/hugsql/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
and throw an exception if mismatch."
[sql-template param-data]
(doseq [k (map :name (filter map? sql-template))]
(when-not (get-in param-data (parameters/deep-get-vec k))
(when-not (contains? param-data (first (parameters/deep-get-vec k)))
(throw (ex-info
(str "Parameter Mismatch: "
k " parameter data not found.") {})))))
Expand Down
5 changes: 4 additions & 1 deletion hugsql-core/test/hugsql/core_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,10 @@
(one-value-param-sqlvec {:x 1})))
(is (thrown-with-msg? ExceptionInfo
#"Parameter Mismatch: :id parameter data not found."
(one-value-param db {:x 1}))))
(one-value-param db {:x 1})))
;; does not throw on false
(is (= ["select * from test where id = ?" false]
(one-value-param-sqlvec {:id false}))))

(testing "database commands/queries"
(condp = db-name
Expand Down

0 comments on commit 5fc2139

Please sign in to comment.