-
-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default quoting needs to be smarter #515
Comments
Why not |
For good or bad, it's existing documented behavior. So there are backward compatibility issues here in spades... |
Would it be acceptable to "hardcode" the different data types that expect a numeric input? (e.g. I know honeysql is meant to be flexible and there are many database providers out there that it's already compatible with (we are using several ourselves). However, it seems to be quite beneficial for the current function to separate between knowing whether it's assessing one of these data type examples and anything else that's a quotable identifier. Happy to conjure up an example in a fork and link it if that's the case. Anyway I can be helpful here - let me know. Thanks |
DDL is out of scope for this issue, so let's stay on topic. I'll just note that the "function-like" behavior in DDL just falls out of general function "syntax" in HoneySQL and is not explicitly programmed at all (because DDL is just too large and irregular a space across multiple databases). If you want to suggest changes to DDL generation, feel free to create a separate issue. |
this is a partial solution, intended to catch (and quote) things like `0abc` while not changing the behavior for `80` or `2023_11_20`
So far, I have updated the code to exclude identifiers like As far as addressing the concerns expressed above and in the PR, I'm still leaning toward an additional, optional regex flag that matches identifies that you want quoted even if they satisfy the existing "OK not to quote" rule. That will definitely come with some caveats: if you provide a regex that matches things like |
Thanks for the work/input here Sean.
So just so I understand, if I (for example) wanted to quote reserved words - I'd pass those in as regex? I do like that suggestion fwiw. |
That is my current thinking, yes. |
Beautiful @seancorfield , thank you very much! |
Derived from discussion around PR #514
It only does that if
:quoted nil
. If you explicitly specify:quoted false
it will turn quoting off. The behavior is::quoted true
-- always quote using the dialect's stropping:quoted nil
-- default: only quote non-alphanumeric entities:quoted false
-- do not quote anythingI gather from your response that the problem you want to solve here is that:
Is that an accurate expression of the problem?
(yes)
Part of the issue is that different dialects have different "must quote" rules.
2023_11_16
is perfectly acceptable to some databases, without quoting, but would require quoting for others. The same applies to the list of reserved words that would need to be quoted when used as column names.A wrinkle in this is DDL that uses things like
[:varchar :80]
and expects that to produceVARCHAR(80)
without quoting"80"
. So, either known DDL contexts must know to override some of the rules (*ddl-no-quote*
perhaps?) or it's completely "caveat programmer" and if we let users provide arbitrary overriding rules, and it breaks their DDL, well then too bad, too sad?The text was updated successfully, but these errors were encountered: