Deprecate AbstractPlatform::quoteIdentifier() #6590
Merged
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.