Fork me on GitHub
#honeysql
<
2022-02-22
>
pinkfrog00:02:42

Hi. How to convert this query into next-jdbc.

update task
set scheduled_at = clock_timestamp() + ?::interval
I don’t how to make the ?::interval part.

seancorfield02:02:58

@i I saw you asked this in #sql as well and got an answer there.

seancorfield02:02:44

The ::type cast syntax is not supported, only the CAST( foo AS bar ) syntax -- and it's explained in the docs.

seancorfield02:02:11

If that syntax works for you, it would be:

dev=> (sql/format {:update :task :set {:scheduled_at [:+ [:clock_timestamp] [:cast "3 minutes" :interval]]}})
["UPDATE task SET scheduled_at = CLOCK_TIMESTAMP() + CAST(? AS interval)" "3 minutes"]

👍 1