Commit 68764374 authored by Benjamin Eberlei's avatar Benjamin Eberlei

Merge pull request #228 from lsmith77/deferred_typo_fix

fixed typo for enabling DEFERRED support
parents 3af9edb2 d3d9fcdd
......@@ -322,7 +322,9 @@ class PostgreSqlPlatform extends AbstractPlatform
$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 @@ class PostgreSqlPlatformTest extends AbstractPlatformTestCase
"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()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment