Permalink
Browse files

Merge pull request #228 from lsmith77/deferred_typo_fix

fixed typo for enabling DEFERRED support
  • Loading branch information...
beberlei committed Nov 16, 2012
2 parents 3af9edb + d3d9fcd commit 687643741c8a1c444d35b4e319b59bb15e3730e3
@@ -322,7 +322,9 @@ public function getAdvancedForeignKeyOptionsSQL(\Doctrine\DBAL\Schema\ForeignKey
$query .= ' NOT DEFERRABLE';
}
- if ($foreignKey->hasOption('feferred') && $foreignKey->getOption('feferred') !== false) {
+ if (($foreignKey->hasOption('feferred') && $foreignKey->getOption('feferred') !== false)
+ || ($foreignKey->hasOption('deferred') && $foreignKey->getOption('deferred') !== false)
+ ) {
$query .= ' INITIALLY DEFERRED';
} else {
$query .= ' INITIALLY IMMEDIATE';
@@ -59,6 +59,46 @@ public function testGeneratesForeignKeySqlForNonStandardOptions()
"CONSTRAINT my_fk FOREIGN KEY (foreign_id) REFERENCES my_table (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE",
$this->_platform->getForeignKeyDeclarationSQL($foreignKey)
);
+
+ $foreignKey = new \Doctrine\DBAL\Schema\ForeignKeyConstraint(
+ array('foreign_id'), 'my_table', array('id'), 'my_fk', array('match' => 'full')
+ );
+ $this->assertEquals(
+ "CONSTRAINT my_fk FOREIGN KEY (foreign_id) REFERENCES my_table (id) MATCH full NOT DEFERRABLE INITIALLY IMMEDIATE",
+ $this->_platform->getForeignKeyDeclarationSQL($foreignKey)
+ );
+
+ $foreignKey = new \Doctrine\DBAL\Schema\ForeignKeyConstraint(
+ array('foreign_id'), 'my_table', array('id'), 'my_fk', array('deferrable' => true)
+ );
+ $this->assertEquals(
+ "CONSTRAINT my_fk FOREIGN KEY (foreign_id) REFERENCES my_table (id) DEFERRABLE INITIALLY IMMEDIATE",
+ $this->_platform->getForeignKeyDeclarationSQL($foreignKey)
+ );
+
+ $foreignKey = new \Doctrine\DBAL\Schema\ForeignKeyConstraint(
+ array('foreign_id'), 'my_table', array('id'), 'my_fk', array('deferred' => true)
+ );
+ $this->assertEquals(
+ "CONSTRAINT my_fk FOREIGN KEY (foreign_id) REFERENCES my_table (id) NOT DEFERRABLE INITIALLY DEFERRED",
+ $this->_platform->getForeignKeyDeclarationSQL($foreignKey)
+ );
+
+ $foreignKey = new \Doctrine\DBAL\Schema\ForeignKeyConstraint(
+ array('foreign_id'), 'my_table', array('id'), 'my_fk', array('feferred' => true)
+ );
+ $this->assertEquals(
+ "CONSTRAINT my_fk FOREIGN KEY (foreign_id) REFERENCES my_table (id) NOT DEFERRABLE INITIALLY DEFERRED",
+ $this->_platform->getForeignKeyDeclarationSQL($foreignKey)
+ );
+
+ $foreignKey = new \Doctrine\DBAL\Schema\ForeignKeyConstraint(
+ array('foreign_id'), 'my_table', array('id'), 'my_fk', array('deferrable' => true, 'deferred' => true, 'match' => 'full')
+ );
+ $this->assertEquals(
+ "CONSTRAINT my_fk FOREIGN KEY (foreign_id) REFERENCES my_table (id) MATCH full DEFERRABLE INITIALLY DEFERRED",
+ $this->_platform->getForeignKeyDeclarationSQL($foreignKey)
+ );
}
public function testGeneratesSqlSnippets()

0 comments on commit 6876437

Please sign in to comment.