DDC-616 - Fixed issue appearing when running the whole test-suite against the changes in the DatabasaeDriver
This commit is contained in:
parent
206710f91a
commit
1d5d092453
@ -48,6 +48,8 @@ class DatabaseDriver implements Driver
|
|||||||
*/
|
*/
|
||||||
private $tables = null;
|
private $tables = null;
|
||||||
|
|
||||||
|
private $classes = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
@ -71,8 +73,7 @@ class DatabaseDriver implements Driver
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($this->_sm->listTableNames() as $tableName) {
|
foreach ($this->_sm->listTableNames() as $tableName) {
|
||||||
$tableName = strtolower($tableName);
|
$tables[strtolower($tableName)] = $this->_sm->listTableDetails($tableName);
|
||||||
$tables[$tableName] = $this->_sm->listTableDetails($tableName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->tables = array();
|
$this->tables = array();
|
||||||
@ -94,15 +95,17 @@ class DatabaseDriver implements Driver
|
|||||||
sort($allForeignKeyColumns);
|
sort($allForeignKeyColumns);
|
||||||
|
|
||||||
if ($pkColumns == $allForeignKeyColumns) {
|
if ($pkColumns == $allForeignKeyColumns) {
|
||||||
if (count($table->getForeignKeys()) != 2) {
|
if (count($table->getForeignKeys()) > 2) {
|
||||||
throw new \InvalidArgumentException("ManyToMany tables with more or less than two foreign keys are not supported by the Database Reverese Engineering Driver.");
|
throw new \InvalidArgumentException("ManyToMany table '" . $name . "' with more or less than two foreign keys are not supported by the Database Reverese Engineering Driver.");
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->manyToManyTables[$name] = $table;
|
$this->manyToManyTables[$name] = $table;
|
||||||
} else {
|
} else {
|
||||||
|
$className = Inflector::classify($name);
|
||||||
$this->tables[$name] = $table;
|
$this->tables[$name] = $table;
|
||||||
|
$this->classes[$className] = $name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -112,15 +115,15 @@ class DatabaseDriver implements Driver
|
|||||||
{
|
{
|
||||||
$this->reverseEngineerMappingFromDatabase();
|
$this->reverseEngineerMappingFromDatabase();
|
||||||
|
|
||||||
|
if (!isset($this->classes[$className])) {
|
||||||
|
throw new \InvalidArgumentException("Unknown class " . $className);
|
||||||
|
}
|
||||||
|
|
||||||
$tableName = Inflector::tableize($className);
|
$tableName = Inflector::tableize($className);
|
||||||
|
|
||||||
$metadata->name = $className;
|
$metadata->name = $className;
|
||||||
$metadata->table['name'] = $tableName;
|
$metadata->table['name'] = $tableName;
|
||||||
|
|
||||||
if (!isset($this->tables[$tableName])) {
|
|
||||||
throw new \InvalidArgumentException("Unknown table " . $tableName . " referred from class " . $className);
|
|
||||||
}
|
|
||||||
|
|
||||||
$columns = $this->tables[$tableName]->getColumns();
|
$columns = $this->tables[$tableName]->getColumns();
|
||||||
$indexes = $this->tables[$tableName]->getIndexes();
|
$indexes = $this->tables[$tableName]->getIndexes();
|
||||||
|
|
||||||
@ -266,6 +269,6 @@ class DatabaseDriver implements Driver
|
|||||||
{
|
{
|
||||||
$this->reverseEngineerMappingFromDatabase();
|
$this->reverseEngineerMappingFromDatabase();
|
||||||
|
|
||||||
return array_map(array('Doctrine\Common\Util\Inflector', 'classify'), array_keys($this->tables));
|
return array_keys($this->classes);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user