hugsql 2024-01-31

How do I translate this to hugsql, where the ids are a parameter?

WITH inputids (id)
AS (VALUES (109734), (109733), (1111111))
SELECT ib.*
FROM inputids ib
LEFT JOIN foo f
ON ib.id = f.id
WHERE f.id IS NULL
So something like
WITH inputids (id)
AS (VALUES :v*:ids)
SELECT ib.*
FROM inputids ib
LEFT JOIN foo f
ON ib.id = f.id
WHERE f.id IS NULL
But working

Oh... That was easy. Thank you!

I did it using :raw and

(defn sqlvals [vals]
  (string/join "," (map #(format "('%s')" %) vals)))
Not the prettiest but it works!

This:

WITH inputids (id)
AS (VALUES :t*:ids)
SELECT ib.*
FROM inputids ib
LEFT JOIN foo f
ON ib.id = f.id
WHERE f.id IS NULL
gives the error count not supported on this type: Long

:ids need to take the expected shape of [[3][2][1]], since this is a list of tuples.