severe export bug fix: classes using column aggregation inheritance not properly exported
This commit is contained in:
parent
5d1d506a3a
commit
07b5727c52
@ -1042,20 +1042,31 @@ class Doctrine_Export extends Doctrine_Connection_Module
|
|||||||
|
|
||||||
// check if class is an instance of Doctrine_Record and not abstract
|
// check if class is an instance of Doctrine_Record and not abstract
|
||||||
// class must have method setTableDefinition (to avoid non-Record subclasses like symfony's sfDoctrineRecord)
|
// class must have method setTableDefinition (to avoid non-Record subclasses like symfony's sfDoctrineRecord)
|
||||||
if ($class->isSubclassOf($parent) && ! $class->isAbstract() && $class->hasMethod('setTableDefinition')
|
// we have to recursively iterate through the class parents just to be sure that the classes using for example
|
||||||
&& $class->getMethod('setTableDefinition')->getDeclaringClass()->getName() == $class->getName()) {
|
// column aggregation inheritance are properly exporterd to database
|
||||||
$record = new $name();
|
while ($class->isAbstract() &&
|
||||||
$table = $record->getTable();
|
! $class->isSubclassOf($parent) &&
|
||||||
$data = $table->getExportableFormat();
|
! $class->hasMethod('setTableDefinition') &&
|
||||||
|
$class->getMethod('setTableDefinition')->getDeclaringClass()->getName() !== $class->getName()) {
|
||||||
$query = $this->conn->export->createTableSql($data['tableName'], $data['columns'], $data['options']);
|
|
||||||
|
|
||||||
if (is_array($query)) {
|
$class = $class->getParent();
|
||||||
$sql = array_merge($sql, $query);
|
|
||||||
} else {
|
if ($class === null) {
|
||||||
$sql[] = $query;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$record = new $name();
|
||||||
|
$table = $record->getTable();
|
||||||
|
$data = $table->getExportableFormat();
|
||||||
|
|
||||||
|
$query = $this->conn->export->createTableSql($data['tableName'], $data['columns'], $data['options']);
|
||||||
|
|
||||||
|
if (is_array($query)) {
|
||||||
|
$sql = array_merge($sql, $query);
|
||||||
|
} else {
|
||||||
|
$sql[] = $query;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$sql = array_unique($sql);
|
$sql = array_unique($sql);
|
||||||
rsort($sql);
|
rsort($sql);
|
||||||
|
Loading…
Reference in New Issue
Block a user