honeysql

Discussion of https://github.com/seancorfield/honeysql :slightly_smiling_face:
deva 2019-05-19T03:41:02.000700Z

@seancorfield How to write something like select concat(IFNULL(S.FIRST_NAME,''),' ',IFNULL(S.LAST_NAME,''),' (',R.DESCRIPTION,')') name from sometable? Do I need to use sql/raw ?

seancorfield 2019-05-19T04:05:20.002Z

@gdrte I'd have to experiment. Mostly that should be regular SQL function call syntax but probably some sql/inline for the values that should not be lifted out as parameters.

seancorfield 2019-05-19T04:13:37.002700Z

Something like

user=> (-> (select #sql/call [:concat #sql/call [:ifnull :firstname #sql/inline "''"] #sql/inline "' '" #sql/call [:ifnull :lastname #sql/inline "''"] #sql/inline "' ('" :description #sql/inline "')'"]) (from :sometable) (h/format))
["SELECT concat(ifnull(firstname, ''), ' ', ifnull(lastname, ''), ' (', description, ')') FROM sometable"]
user=>    
but frankly that is so ugly I wouldn't bother using HoneySQL for this, I'd just use a raw SQL string.

deva 2019-05-19T04:25:27.003400Z

Sure, will go with raw SQL then. Thank you.

deva 2019-05-19T16:44:25.004900Z

I’ve configured hugsql along with honeysql, since by default hugsql uses clojure.java.jdbc, I hope it won’t cause any trouble doing best of both worlds.