Doctrine DBAL
  1. Doctrine DBAL
  2. DBAL-899

Escape table name when update schema

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.4.2
    • Fix Version/s: 2.5
    • Component/s: Platforms
    • Security Level: All
    • Labels:

      Description

      I have a table called by load and a field called by release, but in MySQL these are reserved names, and should be called inside of ``. In my annotations I use like that:

      @ORM\Table(name="`load`") and
      @ORM\Column(name="`release`", length=15)

      These lines work good when use ORM, but when I use schema-tool the `` are ignored and it's generate something like that:

      ALTER TABLE load CHANGE version release VARCHAR(60) DEFAULT NULL;

      And to MySQL it's wrong, the right statement is:

      ALTER TABLE `load` CHANGE version `release` VARCHAR(60) DEFAULT NULL;

        Activity

        Hide
        Marco Pivetta added a comment -

        Guilherme Santos can you verify if master (dbal+orm) fixes this? There has been some work on this issue.

        Show
        Marco Pivetta added a comment - Guilherme Santos can you verify if master (dbal+orm) fixes this? There has been some work on this issue.
        Hide
        Steve Müller added a comment -

        Moved to DBAL, this is unrelated to ORM.

        The table quotation issue has been fixed in 2.5/master in commit: https://github.com/doctrine/dbal/commit/75d35f5809095b37cb7085a9289eca4aa9c6df68

        The column quotation issue is weird. There has been a fix in 2.5/master in commit: https://github.com/doctrine/dbal/commit/5156391b5686a2b3bba628bb0bc1fece63409a44 for the OLD column name but according to your example the NEW column name is not quoted. But that is working for ages already.

        Can you please verify with the latest master as suggested by Marco Pivetta and maybe post the exact generated SQL by the schema tool?

        Show
        Steve Müller added a comment - Moved to DBAL, this is unrelated to ORM. The table quotation issue has been fixed in 2.5/master in commit: https://github.com/doctrine/dbal/commit/75d35f5809095b37cb7085a9289eca4aa9c6df68 The column quotation issue is weird. There has been a fix in 2.5/master in commit: https://github.com/doctrine/dbal/commit/5156391b5686a2b3bba628bb0bc1fece63409a44 for the OLD column name but according to your example the NEW column name is not quoted. But that is working for ages already. Can you please verify with the latest master as suggested by Marco Pivetta and maybe post the exact generated SQL by the schema tool?
        Hide
        Guilherme Santos added a comment -

        It was fixed, a lot of index was changed too, but the quotation works!
        Thanks...

        Show
        Guilherme Santos added a comment - It was fixed, a lot of index was changed too, but the quotation works! Thanks...

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Guilherme Santos
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: