hi please advice how I build this query with #honeysql :
SELECT
CASE
WHEN planned_from_date IS NOT NULL THEN
planned_from_time
ELSE
requested_from_time
END AS from_time
FROM table
thanks
(require '[honeysql.core :as sql])
(require '[honeysql.helpers :refer :all])
(->> (select [(sql/call :case [:<> :planned-from-date nil] :planned-from-time :requested-from-time) :from-time])
(from :table)
Thanks!
Actually seems like there is no ELSE
branch
Got something like this:
CASE WHEN planned_from_date <> nil THEN planned_from_time END AS from_time,
so, almost there 🙂
oops
https://github.com/jkk/honeysql/blob/master/test/honeysql/core_test.cljc#L148
:else blah
so :else :requested-from-time
that case clause implementation is super weird compared to other parts of honeysql
in general, defer to the tests when there's a question about how something works in honeysql
it's not super well documented in prose, but the test coverage is decent for seeing how the unstated pieces are called
Got it, thanks a lot for help!