Doctrine DBAL
  1. Doctrine DBAL
  2. DBAL-835

Old column name not quoted during column rename in MySQL

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.5
    • Component/s: Platforms
    • Security Level: All
    • Labels:
      None
    • Environment:
      CentOS with Doctrine 2.3 MySQL 5.5.31

      Description

      This is a broken feature, because escaping only sometimes (behavior at least in 2.3, if it has not been fixed after that) leads to breaking things. It is possible to CREATE a column named `usage` (without any backticks in the code), but things break from that point on. If I try to change the column name to a non-reserved word later, ALTER TABLE syntax will break

      [Doctrine\DBAL\DBALException]
      An exception occurred while executing 'ALTER TABLE products CHANGE usage purpose VARCHAR(256) NOT NULL':

      SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'usage purpose VARCHAR(256) NOT NULL' at line 1

      Migrating down then again escapes the column name even if it wasn't escaped in the definition.

      I found a ticket from 2012 describing that column names using reserved keywords should be escaped manually, but since migrations will lead into a dead-end with at least using `usage` as a column name, this feature is somewhat broken.

        Issue Links

          Activity

          Hide
          Steve Müller added a comment -

          Arttu Manninen There have been some fixes around quoting identifiers in DDL lately. It seems there is one missing around $oldColumnName in MySqlPlatform::getAlterTableSQL().
          I have moved this issue to DBAL as it is an issue there.

          Show
          Steve Müller added a comment - Arttu Manninen There have been some fixes around quoting identifiers in DDL lately. It seems there is one missing around $oldColumnName in MySqlPlatform::getAlterTableSQL(). I have moved this issue to DBAL as it is an issue there.
          Hide
          Steve Müller added a comment -
          Show
          Steve Müller added a comment - Patch supplied in PR: https://github.com/doctrine/dbal/pull/545
          Hide
          Doctrine Bot added a comment -

          A related Github Pull-Request [GH-545] was closed:
          https://github.com/doctrine/dbal/pull/545

          Show
          Doctrine Bot added a comment - A related Github Pull-Request [GH-545] was closed: https://github.com/doctrine/dbal/pull/545
          Show
          Steve Müller added a comment - Fixed in commit: https://github.com/doctrine/dbal/commit/9d6300fd862478f58a526fbcad0a8f630daa60aa

            People

            • Assignee:
              Steve Müller
              Reporter:
              Arttu Manninen
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: