Fork me on GitHub
#honeysql
<
2022-03-02
>
crankyadmin13:03:34

Hi, I’m working on a project and have a bit of difficulty getting the desired output, here’s what I have:

(h/where :and
            [:>= :total_units 1]
            [:raw "week_beginning >= date '2019-01-01'"]
            (when skus [:in :sku skus]) ;; Good
            (when brands [:in :brand brands]) ;; Good
            (when cat-ids [:regex_like :cat cat-ids]) ;; Bad
            )
regexp_like(cat-ids, '^Thing\|Foo\\|Bar') <--- this is what I’m trying to replicate in Honey. I suspect I need to extend Honey but I’m failing all over the place, could anyone provide any pointers?

crankyadmin13:03:19

skus, brands and cat-ids are all lists.

crankyadmin14:03:05

I ended up just using :raw and built the string up.

seancorfield16:03:50

@crankyadmin cat-ids is a list of strings? You'd need str/join to turn it into the single string argument that regexp_like expects.