Fork me on GitHub
#sql
<
2021-08-21
>
Aviv Kotek21:08:25

hi, using honey.sql couldn't realize how to use IF function with vanilla helpers (I understand how to call fn's) "IF(table.id is NULL, 0, 1))" I eventually did something like this:

(-> (select [[:sum [[:raw "IF(table.id is null, 0, 1))"]]]])
    (from :table)
    sql/format)
how could you achieve this without using :raw ? ty!

seancorfield21:08:14

@aviv There's a dedicated #honeysql FYI but that's like any other function call [:if [:= :table.id nil] 0 1]

👍 2
Aviv Kotek21:08:16

using the REPL mostly and looking on the tests, i'll check this out, thx