honeysql

Discussion of https://github.com/seancorfield/honeysql :slightly_smiling_face:
reefersleep 2019-03-04T10:05:31.003600Z

Is that not syntax for asking whether the scalar value of :foo is one of 1, 2 or 3?

reefersleep 2019-03-04T10:06:04.004300Z

What I want to ask is whether 1 is one of the values in the array value of :foo.

reefersleep 2019-03-04T10:06:45.004800Z

(In my case, the :foo in my schema is an array of strings)

bja 2019-03-04T12:44:00.010800Z

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)

bja 2019-03-04T12:47:07.012700Z

For any(?), You could just use fn calling: (honeysql.core/call :any x)

bja 2019-03-04T12:48:50.014300Z

For @>, syntax you need to implement honeysql.format/fn-handler like in the readme, tests, honeysql.format, or blog posts.

bja 2019-03-04T12:49:18.015100Z

If you search for honeysql @> postgres you'll probably find a bunch of examples

bja 2019-03-04T12:54:05.016200Z

If you're not using postgres, you'll need to use your database specific functions/syntax

reefersleep 2019-03-04T13:53:22.018200Z

@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 🙂