In case anyone missed this in #announcements
I am using honeysql to generate a suffix which I then pass into sql.builder/for-insert-multi
as an option.
The trouble is that the suffix has a param named group
, which needs to be quoted, otherwise PG is unhappy.
Roughly it goes something like this:
(let [suffix (first (hsql/format {:upsert {:on-conflict [:id] :do-update-set [:a :group :b]}}))
insert-multi (sql.builder/for-insert-multi table cols rows {:suffix suffix :column-fn (fn [col] (format "\"%s\"" col))})]
(jdbc/execute! ...))
i may just rename the column, but im curious if anyone has any bright ideas
HoneySQL can do quoting for different databases: it's an option to hsql/format
If you're still using HoneySQL 1.0 or earlier: (hsql/format .. :quoting :ansi)
If you're already using HoneySQL 2.0: (hsql/format .. {:quoted true})
(the ANSI dialect is the default).
^ @devn does that solve your problem?
unfortunately, no. I tried that.
itβs alright, I went ahead and renamed the column
Which version of HoneySQL are you using?
actually, you know what, let me try one more time because i see you have :quoting :ansi bare there (with no wrapping {})
ah yes, thatβll do it β however it still is a bit of a mess to also add in the column-fn transformation. if we run into another instance of this iβll consider switching it up
I realized you must be using 1.0 and the honeysql-postgres extension lib -- :upsert
π
In 2.0, you don't need the extension lib and it's just
user=> (sql/format
#_=> {:on-conflict [:id] :do-update-set [:a :group :b]} {:quoted true})
["ON CONFLICT (\"id\") DO UPDATE SET \"a\" = EXCLUDED.\"a\", \"group\" = EXCLUDED.\"group\", \"b\" = EXCLUDED.\"b\""]
user=>
[honeysql "1.0.444"]
[nilenso/honeysql-postgres "0.2.6"]
ah, nice!
then /that/ is what iβll do to finish out my day π
thanks
Also, since you're on 1.0, make sure you update to 1.0.461 for the important bug fix.
yep, saw that
You can use 1.0 and 2.0 side-by-side and migrate piecemeal: different maven coords and different namespaces π
:male-cook: π π€
https://cljdoc.org/d/seancorfield/honeysql/2.0.0-alpha2/doc/differences-from-1-x