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 workingOh... 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!You can use a tuple list parameter type for this: https://www.hugsql.org/hugsql-in-detail/parameter-types/sql-tuple-list-parameters
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.