Repository navigation
Double a quote character inside an identifier instead of replacing it - #250
Merged
simon-mundy merged 9 commits intoNov 17, 2026
Merged
Conversation
AbstractPlatform defaulted $quoteIdentifierTo to a single quote, so
quoteIdentifier('my"col') rendered "my'col" and named a different
column. SQL-92 escapes an embedded identifier quote by doubling it, so
the default is now '""' and the same name renders "my""col".
The Insert and Update column name tests had the old output as their
expectation for a column named c"d; they now expect "c""d".
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
The IdentifierQuoter, column-name and ORDER BY tests from php-db#241 and php-db#243 pinned the old SQL-92 escaping, which turned an embedded " into '. With this PR's fix the quote is doubled, so a"b now renders "a""b".
tyrsson
previously approved these changes
Nov 17, 2026
Two Sql92Test cases from php-db#248 pinned the old default replacement, which turned an opening quote inside an identifier into '. With this PR the default replacement doubles it, so the expectations become "". The merge also left a test method out of sorted order; mago format restores it.
PredicateIdentifierNameTest from php-db#244 pinned the old SQL-92 escaping of an embedded " as '. With this PR the quote is doubled, so a"b renders "a""b" in every predicate slot.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Adapter\Platform\AbstractPlatformdefaulted$quoteIdentifierToto a single quote. Any platform that keeps the default,Sql92included, rewrote an embedded"instead of escaping it:Fix
SQL-92 escapes a quote inside a delimited identifier by doubling it, so the default is now
'""':MySQL (
``) and PostgreSQL ("") already set this correctly. phpdb-sqlite sets the same wrong value itself and gets its own fix in php-db/phpdb-sqlite.Tests
Sql92Testcover a quote inside a name, a lone quote, adjacent quotes, and a single quote left alone. They run against bothSql92and the bareAbstractPlatform, and they fail without the fix.InsertColumnNameTestandUpdateColumnNameTesthad the old output as their expectation for a column namedc"d. They now expect"c""d".mago format --check,mago lintandmago analyzeare clean, and the unit suite passes (2,332 tests).Not changed here
quoteIdentifierChain()still escapes"with a backslash.quoteIdentifierInFragment()still splits a"out of a name as its own piece. Quote Select, join and GROUP BY column names as identifiers #241, Quote ORDER BY names as identifiers where fragment quoting breaks them #243 and Quote predicate names as identifiers where fragment quoting renders broken SQL #244 cover that path.