This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-08-21
Channels
- # babashka (11)
- # beginners (15)
- # cider (2)
- # cljdoc (36)
- # cljsrn (3)
- # clojure (6)
- # clojure-europe (9)
- # clojurescript (17)
- # conjure (3)
- # deps-new (6)
- # development-containers (1)
- # emacs (3)
- # fulcro (4)
- # gratitude (14)
- # introduce-yourself (2)
- # joker (14)
- # lsp (1)
- # luminus (7)
- # malli (6)
- # polylith (7)
- # releases (1)
- # reveal (3)
- # sql (4)
- # vim (18)
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!@aviv There's a dedicated #honeysql FYI but that's like any other function call [:if [:= :table.id nil] 0 1]
The web app that John Shaffer built is very helpful for experimenting with expressions: https://www.john-shaffer.com/honeysql/?q=%7B%3Aselect%20%5B%20%5B%20%5B%3Asum%20%5B%3Aif%20%5B%3A%3D%20%3Atable.id%20nil%5D%200%201%5D%5D%20%3Atotal%20%5D%20%5D%0A%20%3Afrom%20%3Atable%7D&opt=%7B%3Apretty%20true%7D
using the REPL mostly and looking on the tests, i'll check this out, thx