hugsql

apeel 2019-10-25T15:56:49.002200Z

Having trouble getting a snippet to work. Am I writing it incorrectly?

-- :snip example-snip
SELECT :id AS "foo/id"

-- :name get-client-by-core-id :query :one
-- :doc Fetch a client by core client id
:snip:example-snip
FROM clients
where core_client_id = :foo/core-client-id;
Getting exception
Parameter Mismatch: :example-snip parameter data not found.
Using this with conman.

curtis.summers 2019-10-25T15:59:03.002900Z

What does your function call look like?

apeel 2019-10-25T16:18:43.003900Z

(db/get-client-by-core-id query-args) It has the same form as it did before I tried converting to snippets.

curtis.summers 2019-10-25T17:54:53.006300Z

Snippets have their own set of parameters, so the query args should have a {:example-snip {:id 1}}. You probably want something like fragments, but those don't exist yet: https://github.com/layerware/hugsql/issues/36

apeel 2019-10-25T18:11:18.008600Z

ah, okay. When I was looking at the snippets doc, I thought the snip-query example was focused on explaining use of the

-- :snip cond-snip
so didn't look into it too closely.

apeel 2019-10-25T18:17:28.008800Z

thanks for the help!