Does honeysql support this syntax? ["col = ANY(?)" (int-array data)]
[:= :col [:any (int-array data)]].
Nice, thanks @p-himik
Is there a way to add ::integer[] ?
E.g.,: ["col = ANY(?::integer[])" (int-array data)]
:cast
The array type is a bit tricky since [] are not legal in keywords but you could do:
user=> (sql/format [:cast [:any (into-array (range 4))] [:raw "integer[]"]])
["CAST(ANY(?) AS integer[])" #object["[Ljava.lang.Long;" 0x2e1ddc90 "[Ljava.lang.Long;@2e1ddc90"]]Hmm, no, you'll want cast inside any... just a sec...
Something like this...
user=> (sql/format [:= :col [:any [:cast (into-array (range 4)) [:raw "integer[]"]]]])
["col = ANY(CAST(? AS integer[]))" #object["[Ljava.lang.Long;" 0x63d4f0a2 "[Ljava.lang.Long;@63d4f0a2"]]Ok right, I see. Thank you. I'm new to postgres so I wasn't sure yet if CAST was the exact same, but I guess it is.
CAST( x AS y ) is the portable SQL version. x::y is not as widely supported AFAIK.
There's a separate syntax for when you need array[1, 2, 3]::integer[] - [:array [1 2 3] :integer]. Doesn't seem applicable here though. And I'm not sure whether it could be extended or not to support Java array values.