hugsql
hugsql copied to clipboard
Optional null parameters
Hi, thanks for the great lib!
Currently if my sql insert script is like
-- :name add-person
insert into table (id, name, address) values (:id, :name, :address)
and everything but id accept nulls I'm forced to do
(add-person db {:id 1, :name nil, :address nil})
or I get a missing parameter error.
Is there a way of just calling it like :
(add-person db {:id 1})
Thanks!!
You can try something like this:
-- :name add-person :<! :1
INSERT INTO table (:i*:fields)
VALUES :tuple:values RETURNING *;
then
(add-person db {:fields [...] :values [...]})