honeysql

Discussion of https://github.com/seancorfield/honeysql :slightly_smiling_face:
ag 2020-03-16T00:16:24.024700Z

can someone help me to translate the following sql snippet into plain honeysql query:

with grants as
  (select * from grants_table
    where (user_id = 'foo'))
select * from grants
I know how to write something like:
:select :* :from  :grants-table
:where [:= :user-id "foo"]
But I can’t make it work with “with as”

ag 2020-03-16T00:43:42.026400Z

I think I figured it out, it’ll be something like:

:with [[:grants {:select [:*] :from [:grants-table] :where [:= :user-id "foo]}]]
:select :* :from :grants

ag 2020-03-16T00:54:19.027Z

Ah. Now I’m struggling with the following construct:

select (case
          when ( count(*) < 0 ) then 'yes'
          else 'no'
        end)
from my_table
how do you write this in Honey?

ag 2020-03-16T01:38:56.027900Z

ah, seems it involves using sql/call