1
0
mirror of synced 2025-01-31 04:21:44 +03:00

[2.0] Fix to DatabaseDriver so drivers that don't support foreign keys will still work

This commit is contained in:
jwage 2009-10-08 18:54:19 +00:00
parent 98cf9017a8
commit 6fd2eaa45d

View File

@ -68,7 +68,11 @@ class DatabaseDriver implements Driver
$metadata->primaryTable['name'] = $tableName;
$columns = $this->_sm->listTableColumns($tableName);
$foreignKeys = $this->_sm->listTableForeignKeys($tableName);
try {
$foreignKeys = $this->_sm->listTableForeignKeys($tableName);
} catch (\Doctrine\Common\DoctrineException $e) {
$foreignKeys = array();
}
$ids = array();
$fieldMappings = array();
@ -102,7 +106,9 @@ class DatabaseDriver implements Driver
}
if ($ids) {
$metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO);
if (count($ids) == 1) {
$metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO);
}
foreach ($ids as $id) {
$metadata->mapField($id);