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 checking keywords in schema object names #5431

Merged
merged 1 commit into from
Jun 4, 2022

Conversation

morozov
Copy link
Member

@morozov morozov commented Jun 4, 2022

Q A
Type deprecation

Here's an example of running the command on the database produced by the ORM test suite:

$ bin/doctrine-dbal dbal:reserved-words -l mysql -l pgsql
[Warning] The use of this script is discouraged. You find instructions on how to
boostrap the console runner in our documentation.

Checking keyword violations for mysql, pgsql...
There are 4 reserved keyword violations in your database schema:
  - Table ddc2602biographyfieldchoice column label keyword violations: MySQL
  - Table ddc2602biographyfield column label keyword violations: MySQL
  - Table table keyword violations: MySQL, PostgreSQL
  - Table decimal_model column decimal keyword violations: MySQL

The logic behind the functionality of checking keywords in schema object names is flawed:

  1. There is no rule that the usage of reserved keywords in schema object names violates. The DBAL can quote object names in some places. Furthermore, the very fact that the DBAL managed to deploy the schema with such object names and (probably) use it for queries, means that they are valid.
  2. More importantly than handling reserved keywords, the DBAL is poor at handling the names that aren't reserved keywords but still don't comply with the SQL syntax and thus need to be quoted (e.g. the ones that start with a digit or contain a dot). But this command doesn't report them.
  3. The output of this command is mostly false-positive. If, in theory, it outputs some useful line item, there will be no way a user can find it among all the noise.
  4. The DBAL isn't the source of truth on the list of reserved keywords for a given platform, the DBAL's version of such lists is never complete. The DBAL doesn't define the SQL syntax either. So it cannot be relied upon as the source of truth about which identifiers need to be escaped and which don't.

@morozov morozov added this to the 3.4.0 milestone Jun 4, 2022
@morozov morozov marked this pull request as ready for review June 4, 2022 14:59
@morozov morozov requested review from greg0ire and derrabus June 4, 2022 14:59
Copy link
Member

@greg0ire greg0ire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another command I haven't use in my lifetime… let's go 👍

@morozov morozov merged commit 4be7e2f into doctrine:3.4.x Jun 4, 2022
@morozov morozov deleted the deprecate-keyword-validator branch June 4, 2022 15:31
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 5, 2023
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