Is that not syntax for asking whether the scalar value of :foo
is one of 1
, 2
or 3
?
What I want to ask is whether 1
is one of the values in the array value of :foo
.
(In my case, the :foo
in my schema is an array of strings)
There isn't out of the box syntax for arrays in honeysql (to my knowledge). This is very easy to add (honeysql is meant to be extended to database specific syntax). Here are some blog posts with examples: http://tech.toryanderson.com/tags/honeysql/
I think the postgres syntax for this is where ? = any(y)
. If you use gin/gist indexing, you could also say: where y @> ?
where ? is (honeysql.types/array x)
For any(?), You could just use fn calling: (honeysql.core/call :any x)
For @>, syntax you need to implement honeysql.format/fn-handler like in the readme, tests, honeysql.format, or blog posts.
If you search for honeysql @> postgres you'll probably find a bunch of examples
If you're not using postgres, you'll need to use your database specific functions/syntax
@bja cheers! I’m using Postgres and think I’ve actually seen the @>
stuff before. I was just wondering if perhaps I was overlooking some predefined Honeysql syntax. I’m sure somebody has already built the Honeysql extension that I need, or I can do it myself with the help of the documentation you suggest 🙂