Fork me on GitHub
#hugsql
<
2020-01-09
>
borkdude20:01:40

I have this query:

-- :name do-update-feed-title! :<!
update articles set meta = meta::jsonb - 'feed-title' ||
--~ (format "{\"feed-title\": %s}" (:title params))
where source = :source;
As you can see I'm trying a Clojure expression inside the query. But it seems that hugsql is still trying to interpret this as sql and substitute something where it shouldn't?
Parameter Mismatch: :  parameter data not found.

borkdude20:01:43

I need to produce something like:

update articles set meta = meta::jsonb - 'feed-title' || '{"feed-title":"Pharmaceutical Business Review - Drug Discovery"}'
where source = '';

curtis.summers20:01:05

@borkdude It might be that you need to escape that colon, since clojure expressions can return hugsql parameters to be evaluated.

curtis.summers20:01:56

Might need two, since it's in a string already:

--~ (format "{\"feed-title\"\\: %s}" (:title params))