Skip to content
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

Improve identifier escaping #163

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

donatj
Copy link

@donatj donatj commented Mar 14, 2024

The diff on this is larger than in actuality because phpcbf needs to be ran.

Merging #162 will clear that up.

I have a field with a backtick in a mysql database (absolutely insane, I know, not my choice) - and found that I was breaking out of the identifier name.

This improves the quoting of of identifiers across the board.

  • Common SQL specifies a quote is quoted by doubling the quote, so a"b is quoted as "a""b"
  • MySQL specifies that a single backtick becomes a double backtick, so a`b is quoted as `a``b`
  • MS-SQL when using brackets only wants you to quote the closing brackets, so a[b] is quoted as a[b]]]

I changed Sqlite to target CommonSQL as it matches the behaviour - see: https://www.sqlite.org/lang_keywords.html

More than happy to make any requested changes. Let me know

@donatj donatj requested a review from shadowhand as a code owner March 14, 2024 18:48
@donatj donatj mentioned this pull request Mar 14, 2024
@donatj
Copy link
Author

donatj commented Mar 19, 2024

It strikes me this might cause issues with things like table.column… Hmm. I'm pondering on this after all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant