Commit ff630e2a authored by Lukas Kahwe Smith's avatar Lukas Kahwe Smith Committed by Martin Hasoň

Add support for deferred foreign key constraints for in sqlite

parent cb440e1e
...@@ -301,6 +301,12 @@ class SqlitePlatform extends AbstractPlatform ...@@ -301,6 +301,12 @@ class SqlitePlatform extends AbstractPlatform
} }
} }
if (isset($options['unique']) && ! empty($options['unique'])) {
foreach ($options['unique'] as $index => $indexDef) {
$query[] = $this->getCreateIndexSQL($indexDef, $name);
}
}
return $query; return $query;
} }
...@@ -330,7 +336,7 @@ class SqlitePlatform extends AbstractPlatform ...@@ -330,7 +336,7 @@ class SqlitePlatform extends AbstractPlatform
public function getListTableColumnsSQL($table, $currentDatabase = null) public function getListTableColumnsSQL($table, $currentDatabase = null)
{ {
$table = str_replace(".", "__", $table); $table = str_replace('.', '__', $table);
return "PRAGMA table_info($table)"; return "PRAGMA table_info($table)";
} }
...@@ -373,6 +379,25 @@ class SqlitePlatform extends AbstractPlatform ...@@ -373,6 +379,25 @@ class SqlitePlatform extends AbstractPlatform
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function getAdvancedForeignKeyOptionsSQL(ForeignKeyConstraint $foreignKey)
{
$query = parent::getAdvancedForeignKeyOptionsSQL($foreignKey);
if ($foreignKey->hasOption('deferrable') && $foreignKey->getOption('deferrable') !== false) {
$query .= ' DEFERRABLE';
} else {
$query .= ' NOT DEFERRABLE';
}
if ($foreignKey->hasOption('deferred') && $foreignKey->getOption('deferred') !== false) {
$query .= ' INITIALLY DEFERRED';
} else {
$query .= ' INITIALLY IMMEDIATE';
}
return $query;
}
public function supportsIdentityColumns() public function supportsIdentityColumns()
{ {
return true; return true;
...@@ -392,6 +417,7 @@ class SqlitePlatform extends AbstractPlatform ...@@ -392,6 +417,7 @@ class SqlitePlatform extends AbstractPlatform
public function getTruncateTableSQL($tableName, $cascade = false) public function getTruncateTableSQL($tableName, $cascade = false)
{ {
$tableName = str_replace('.', '__', $tableName); $tableName = str_replace('.', '__', $tableName);
return 'DELETE FROM '.$tableName; return 'DELETE FROM '.$tableName;
} }
......
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