Deprecate AbstractPlatform::quoteIdentifier()#6590
Merged
morozov merged 1 commit intodoctrine:4.3.xfrom Nov 11, 2024
Merged
Conversation
derrabus
approved these changes
Nov 11, 2024
greg0ire
added a commit
that referenced
this pull request
Jan 25, 2025
Right now, the message is confusing, it looks like this: > 4) /home/greg/dev/doctrine-orm/patch/vendor/doctrine/deprecations/src/Deprecation.php:208 Use quoteSingleIdentifier() individually for each part of a qualified name instead. (AbstractPlatform.php:1214 called by DefaultQuoteStrategy.php:27, #6590, package doctrine/dbal)
greg0ire
added a commit
to greg0ire/dbal
that referenced
this pull request
Jan 25, 2025
Right now, the message is confusing, it looks like this: > 4) /home/greg/dev/doctrine-orm/patch/vendor/doctrine/deprecations/src/Deprecation.php:208 Use quoteSingleIdentifier() individually for each part of a qualified name instead. (AbstractPlatform.php:1214 called by DefaultQuoteStrategy.php:27, doctrine#6590, package doctrine/dbal)
greg0ire
added a commit
to greg0ire/doctrine-orm
that referenced
this pull request
Jan 26, 2025
We should be using quoteSingleIdentifier(), assuming we only ever pass single identifiers here. See doctrine/dbal#6590
This was referenced Jan 26, 2025
n0099
added a commit
to n0099/open-tbm
that referenced
this pull request
Aug 13, 2025
…entifier()` with `quoteSingleIdentifier()` that deprecated in doctrine/dbal#6590 @ `App\Doctrine\AlwaysQuoteStrategy` @ be
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
The current implementation of the method is pointless. The purpose of quoting an identifier in SQL is to prevent its value from being interpreted as SQL and retain its literal value. Thus, identifiers containing special characters (e.g. dots or spaces) need to be quoted.
An SQL name consists of one (unqualified) or more (qualified) identifiers separated with a dot, where each of them may be quoted individually.
The current implementation parses the provided identifier as a qualified name before quoting. So if the provided value contains a dot, it will be interpreted as part of the SQL syntax. This is the opposite of what quoting an identifier is for.
Method naming issues
A method named
quoteIdentifier()should do exactly whatquoteSingleIdentifier()does. The "single" qualifier inquoteSingleIdentifier()is redundant. Multiple identifiers cannot be parsed or quoted together. Unfortunately, we cannot just renamequoteSingleIdentifier()toquoteIdentifier()in 5.0.Another approach would be to introduce
enquoteIdentifier()similar to JDBC. This way, we could deprecate both of the existing methods in favor of this one. However, it would be inconsistent in naming with the rest of the "quote" methods.Given that there's no obvious better naming, I'm leaving it as is for now and I'm open to ideas.
Changes in the tests
In the modified tests,
quoteIdentifier()was used wherequoteSingleIdentifier()should have been used (quoting an identifier, not a qualified name). Quite likely, such an issue exists in the code of the applications that depend on the DBAL. These test modifications are acceptable as they don't compensate for any breaking changes. On the contrary, they improve the documentation aspect of the tests.