Hello, good people! I am not able to find out how to make Honey produce truncate table cascade
I have tried (assoc (hh/truncate _:table_) :raw "cascade") but that renders "CASCADE TRUNCATE table" 😭 🙏
(sql/format {:truncate [:my-table :cascade]})
=> ["TRUNCATE my_table CASCADE"]And with a helper function:
(sql/format (hh/truncate [:my-table :cascade]))
=> ["TRUNCATE my_table CASCADE"]many thanks! I would never have figured that out 😅
Searching on GitHub brings answers in the speediest of manners. :)
What did you search? I searched the honesql GH repo for “cascade” in vain
That's actually exactly what I did. It's just that I look at commits and issues as well.
The search landed me on this commit where I quickly saw the highlighted line which made it obvious how to specify :cascade: https://github.com/seancorfield/honeysql/commit/e8ea9283cc3cae5939750a0b540518143b87ff39#diff-49952233047493b6ede50abf2fce16b71d9c717d3b7c050f64e86a4514a1db1bR599
Can honeysql quote table and column names to prevent clashes with names reserved by the DBRMS and are there any strong opinions about whether or not one should do this?
Yes, quoting is very well documented. And you should definitely do that. There's no good reason not to quote your identifiers.
Ah, I found the relevant part in the doc. I guess the deeper question is, should one avoid using reserved words even if one is quoting?
I would say no. E.g. "order" is way too good of a name to pass it up just because the DB reserved it in its unquoted form.
But you probably shouldn't name your columns &%!@# even if quoted. ;)
yeah, that seems fair
thanks for sharing your opinion