honeysql

Discussion of https://github.com/seancorfield/honeysql :slightly_smiling_face:
bja 2017-12-12T21:41:58.000274Z

I seem to be doing something weird with 0.9.1/master where the test case for insert-into passes (using honeysql.format/format-clause) but inserts an extra set of parens when called with honeysql.core/format

bja 2017-12-12T21:43:27.000350Z

the third insert-into-test here: https://github.com/jkk/honeysql/blob/master/test/honeysql/format_test.cljc#L60 passes for me, but the same map has an extra set of parens around the SELECT (as though we didn't set *subquery?* to be false) when built with honeysql.core/format

bja 2017-12-12T21:44:14.000503Z

user=> (honeysql.core/format {:insert-into [[:foo [:a :b :c]] {:select [:d :e :f] :from [:baz]}]})
["INSERT INTO foo (a, b, c) (SELECT d, e, f FROM baz)"]
user=> (honeysql.format/format-clause (first {:insert-into [[:foo [:a :b :c]] {:select [:d :e :f] :from [:baz]}]}) nil)
"INSERT INTO foo (a, b, c) SELECT d, e, f FROM baz"

bja 2017-12-12T21:49:55.000229Z

it appears that patching https://github.com/jkk/honeysql/blob/master/src/honeysql/format.cljc#L543 to wrap with a

(binding [*subquery?* false] ...)
gets honeysql.core/format to behave the same as honeysql.format/format-clause

bja 2017-12-12T22:14:49.000011Z

fixed in this PR: https://github.com/jkk/honeysql/pull/196/files