DBAL-313: When creating foreign key constraints, the AbstractPlatform class does not quote the referenced table. #1496

Closed
doctrinebot opened this Issue Aug 6, 2012 · 6 comments

2 participants

@doctrinebot

Jira issue originally created by user majoyal:

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 FK476F5DE7B196EE6E FOREIGN KEY (rightid) REFERENCES right (id)

@doctrinebot

Comment created by @FabioBatSilva:

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..

@doctrinebot

Comment created by posulliv:

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);
}  
@doctrinebot

Comment created by stof:

Can you paste your mapping for your right entity ?

@doctrinebot

Comment created by @asm89:

Can you provide us with more feedback?

@doctrinebot

Comment created by @beberlei:

Seems fixed as per comment of Patrick.

@doctrinebot

Issue was closed with resolution "Fixed"

@doctrinebot doctrinebot added the Bug label Dec 6, 2015
@beberlei beberlei was assigned by doctrinebot Dec 6, 2015
@doctrinebot doctrinebot added this to the 2.4 milestone Dec 6, 2015
@doctrinebot doctrinebot closed this Dec 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment