Skip to content

Deprecate AbstractPlatform::quoteIdentifier()#6590

Merged
morozov merged 1 commit intodoctrine:4.3.xfrom
morozov:deprecate-quote-identifier
Nov 11, 2024
Merged

Deprecate AbstractPlatform::quoteIdentifier()#6590
morozov merged 1 commit intodoctrine:4.3.xfrom
morozov:deprecate-quote-identifier

Conversation

@morozov
Copy link
Copy Markdown
Member

@morozov morozov commented Nov 11, 2024

Q A
Type deprecation

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 what quoteSingleIdentifier() does. The "single" qualifier in quoteSingleIdentifier() is redundant. Multiple identifiers cannot be parsed or quoted together. Unfortunately, we cannot just rename quoteSingleIdentifier() to quoteIdentifier() 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 where quoteSingleIdentifier() 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.

@morozov morozov added this to the 4.3.0 milestone Nov 11, 2024
@morozov morozov marked this pull request as ready for review November 11, 2024 03:09
@morozov morozov requested review from derrabus and greg0ire November 11, 2024 03:09
@morozov morozov merged commit 8879eb2 into doctrine:4.3.x Nov 11, 2024
@morozov morozov deleted the deprecate-quote-identifier branch November 11, 2024 14:25
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
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
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants