Doctrine DBAL
  1. Doctrine DBAL
  2. DBAL-313

When creating foreign key constraints, the AbstractPlatform class does not quote the referenced table.

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.2.2
    • Fix Version/s: 2.4
    • Component/s: Platforms
    • Security Level: All
    • Labels:
      None

      Description

      I have a table that is using a reserved MySQL keyword (right) and it's quoted in all the generated SQL but not in the foreign key constraint.

      When I use doctrine.php orm:schema-tool:create I get this SQL line:
      ALTER TABLE website ADD CONSTRAINT FK_476F5DE7B196EE6E FOREIGN KEY (right_id) REFERENCES right (id)

        Activity

        Marc-André Joyal created issue -
        Hide
        Fabio B. Silva added a comment -

        Hi,

        Could you try it with doctrine 2.3 ?
        There are lot of changes about quotes.
        if it fails even with 2.3 changes please attach your entities.

        Thanks..

        Show
        Fabio B. Silva added a comment - Hi, Could you try it with doctrine 2.3 ? There are lot of changes about quotes. if it fails even with 2.3 changes please attach your entities. Thanks..
        Hide
        Padraig O'Sullivan added a comment - - edited

        I verified this is fixed in trunk by creating a test. Worth creating pull request to add test case?

        public function testQuotedForeignKeySQL()
        {   
            $tableOld = new Table("website");
            $tableOld->addColumn('right_id', 'integer');
            $tableOld->addUnnamedForeignKeyConstraint('right', array('right_id'), array('id'));
        
            $sqls = array();
            foreach ($tableOld->getForeignKeys() AS $fk) {
                $sqls[] = $this->platform->getCreateForeignKeySQL($fk, $tableOld);
            }   
        
            $this->assertEquals(array("ALTER TABLE website ADD CONSTRAINT FK_476F5DE754976835 FOREIGN KEY (right_id) REFERENCES `right` (id)"), $sqls);
        }  
        
        Show
        Padraig O'Sullivan added a comment - - edited I verified this is fixed in trunk by creating a test. Worth creating pull request to add test case? public function testQuotedForeignKeySQL() { $tableOld = new Table( "website" ); $tableOld->addColumn('right_id', 'integer'); $tableOld->addUnnamedForeignKeyConstraint('right', array('right_id'), array('id')); $sqls = array(); foreach ($tableOld->getForeignKeys() AS $fk) { $sqls[] = $ this ->platform->getCreateForeignKeySQL($fk, $tableOld); } $ this ->assertEquals(array( "ALTER TABLE website ADD CONSTRAINT FK_476F5DE754976835 FOREIGN KEY (right_id) REFERENCES `right` (id)" ), $sqls); }
        Hide
        Christophe Coevoet added a comment -

        Can you paste your mapping for your right entity ?

        Show
        Christophe Coevoet added a comment - Can you paste your mapping for your right entity ?
        Alexander made changes -
        Field Original Value New Value
        Status Open [ 1 ] Awaiting Feedback [ 10000 ]
        Hide
        Alexander added a comment -

        Can you provide us with more feedback?

        Show
        Alexander added a comment - Can you provide us with more feedback?
        Benjamin Eberlei made changes -
        Status Awaiting Feedback [ 10000 ] Open [ 1 ]
        Hide
        Benjamin Eberlei added a comment -

        Seems fixed as per comment of Patrick.

        Show
        Benjamin Eberlei added a comment - Seems fixed as per comment of Patrick.
        Benjamin Eberlei made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Benjamin Eberlei made changes -
        Fix Version/s 2.4 [ 10320 ]

        This list may be incomplete, as errors occurred whilst retrieving source from linked applications:

        • Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={query=DBAL-313, expand=changesets[0:20].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Marc-André Joyal
          • Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: