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

Deprecate AbstractPlatform::quoteIdentifier() #6590

Merged
merged 1 commit into from
Nov 11, 2024

Conversation

morozov
Copy link
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 greg0ire and derrabus November 11, 2024 03:09
@morozov morozov merged commit 8879eb2 into doctrine:4.3.x Nov 11, 2024
90 of 91 checks passed
@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants