1
0
mirror of synced 2024-12-13 22:56:04 +03:00

severe export bug fix: classes using column aggregation inheritance not properly exported

This commit is contained in:
zYne 2007-09-01 16:11:58 +00:00
parent 5d1d506a3a
commit 07b5727c52

View File

@ -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']); $class = $class->getParent();
if (is_array($query)) { if ($class === null) {
$sql = array_merge($sql, $query); break;
} else {
$sql[] = $query;
} }
} }
$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);