hugsql

borkdude 2020-01-09T20:02:40.001100Z

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.

borkdude 2020-01-09T20:05:43.001700Z

I need to produce something like:

update articles set meta = meta::jsonb - 'feed-title' || '{"feed-title":"Pharmaceutical Business Review - Drug Discovery"}'
where source = '<http://drugdiscovery.pharmaceutical-business-review.com/rss>';

curtis.summers 2020-01-09T20:19:05.003200Z

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

curtis.summers 2020-01-09T20:20:56.004500Z

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

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

curtis.summers 2020-01-09T20:21:30.004900Z

https://www.hugsql.org/#colon

borkdude 2020-01-09T20:50:23.005200Z

@curtis.summers That's it, thanks