Hi! How do I tell Honey that DEFAULT is a Postgres keyword and not a column name that should be quoted? This
(-> (hh/update table)
(hh/set {:col :DEFAULT})
(honey.sql/format {:quoted true}))
produces UPDATE "snapshot" SET "col" = "DEFAULT" while I need UPDATE "snapshot" SET "col" = DEFAULT . I did not find anything in the docs other than [:raw "DEFAULT"] . Is that it, or is there a better way? Thank you!Try using [:default] instead of :DEFAULT.
Doesn’t that produce default() which is a function call?
You're a single REPL execution away from checking. ;)
(sql/format {:update :t
:set {:col [:default]}})
=> ["UPDATE t SET col = DEFAULT"][...] is context-dependent.
You are right. Sometimes I feel HoneySQL is too magic and beyond my understanding… 😅
thanks a lot!
Addendum to my "context-dependent" message - [...] is also content-dependent.
E.g. :default in a vector expands to DEFAULT but :x expands to x(). So in this case it's just that HoneySQL treats :default in a special way.
I don't want to be that guy but... https://cljdoc.org/d/com.github.seancorfield/honeysql/2.4.1026/doc/getting-started/sql-special-syntax-#constraint-default-references has examples 🙂
But, yes, the docs for :update could certainly be beefed up...
Ah, I have been on the page but haven't thought of searching it for default 😅
Feel free to add notes to https://github.com/seancorfield/honeysql/issues/489