well, this is curious…
(honeysql.helpers/columns (honeysql.core/raw "col1") (honeysql.core/raw "\"col.2\"") (honeysql.core/raw "col.3"))
=> #sql/raw"col1"
(honeysql.helpers/columns (keyword "col1") (honeysql.core/raw "\"col.2\"") (honeysql.core/raw "col.3"))
=> {:columns (:col1 #sql/raw"\"col.2\"" #sql/raw"col.3")}
Yeah, I suspect there's an edge case with merging data on that first column. Put {}
before the first column name.
aha, yep, that did it
better than what I was planning
user=> (columns (sql/raw "col1") (sql/raw "col.two") (sql/raw "col:three"))
#sql/raw "col1"
user=> (columns {} (sql/raw "col1") (sql/raw "col.two") (sql/raw "col:three"))
{:columns (#sql/raw "col1" #sql/raw "col.two" #sql/raw "col:three")}
Normally you'd thread a hash map into the helper call.
user=> (-> {} (columns (sql/raw "col1") (sql/raw "col.two") (sql/raw "col:three")))
{:columns (#sql/raw "col1" #sql/raw "col.two" #sql/raw "col:three")}
Nearly all the helpers expect to be used in that context.
ah, right. hence the insert-into
example from the README
HoneySQL v2 gets it right:
user=> (columns [:raw "col1"] [:raw "col.two"] [:raw "col:three"])
{:columns [[:raw "col1"] [:raw "col.two"] [:raw "col:three"]]}
thanks a lot, Sean! this is extremely helpful. I will definitely be looking for us to upgrade to v2 once it’s released 🙂
in the meantime, I can finally explain the hiccup we ran into in the 0.9.4->1.0.461 upgrade in 0.9.4:
(honeysql.helpers/columns {} (honeysql.core/raw "col1"))
=> {:columns (#sql/raw"col1")}
(honeysql.helpers/columns (honeysql.core/raw "col1"))
=> {:columns (#sql/raw"col1")}
in 1.0.461:
(honeysql.helpers/columns (honeysql.core/raw "a.b"))
=> #sql/raw"a.b"
(honeysql.helpers/columns {} (honeysql.core/raw "a.b"))
Execution error (IllegalArgumentException) at honeysql.helpers/check-varargs (helpers.cljc:264).
columns takes varargs, not a single collection
i.e. this patch: https://github.com/seancorfield/honeysql/commit/4ca74f2b0d0f87827ce34d9baf8dcc8d086ce18e
so now that I clearly understand it, I can work around
Ah, back in 0.9.7... yeah, with hindsight there was a lot more churn in the 0.9.x releases than there should have been and definitely not enough test coverage 😞
FYI, re: 2.0 -- the main thing blocking a "gold" release is actually documentation, to be honest. At this point the functionality isn't going to change (beyond supporting more ANSI SQL and probably more PostgreSQL syntax).
(but I understand some folks are reluctant to use an alpha in production)