#1412: Doctrine::createTablesFromModels() fails to build records related to
abstract records
-----------------------------------+----------------------------------------
Reporter: bschussek | Owner: romanb
Type: defect | Status: new
Priority: major | Milestone: New
Component: Relations | Version: 0.11
Keywords: | Has_test: 0
Mystatus: Pending Core Response | Has_patch: 0
-----------------------------------+----------------------------------------
I will give a small schema example here (exemplary only, I haven't tested
it):
{{{
detect_relations: true
Tree:
columns:
name: string
# this class is declared abstract in the model
Fruit:
columns:
color: string
tree_id: integer
Apple:
inheritance:
extends: Fruit
type: concrete
Orange:
inheritance:
extends: Fruit
type: concrete
}}}
Without the relation Fruit->Tree, this example works perfectly fine. I end
up with the tables "tree", "apple" and "orange" which is what I want.
Once I add the relation Fruit->Tree though, Doctrine has problems. When
building the SQL for Tree, it tries to build the definitions of all
related records (Fruit). In the process of this definition building
Doctrine tries to instantiate the abstract class Fruit, which fails (of
course).
The relevant part of the exception trace looks like the following:
{{{
0.8678 11145488 11. Doctrine::createTablesFromModels()
0.8678 11145488 12. Doctrine_Export->exportSchema()
.../Doctrine.php:785
0.9576 21315824 13. Doctrine_Export->exportClasses()
.../Doctrine/Export.php:1047
0.9576 21315824 14. Doctrine_Export->exportSortedClassesSql()
.../Doctrine/Export.php:1134
1.0938 24182320 15. Doctrine_Export->exportClassesSql()
.../Doctrine/Export.php:1066
1.0942 24182320 16. Doctrine_Table->getExportableFormat()
.../Doctrine/Export.php:1186
1.0943 24182396 17. Doctrine_Table->getRelations()
.../Doctrine/Table.php:628
1.0943 24182396 18. Doctrine_Relation_Parser->getRelations()
.../Doctrine/Table.php:862
1.0948 24185448 19. Doctrine_Relation_Parser->getRelation()
.../Doctrine/Relation/Parser.php:238
1.0948 24185448 20. Doctrine_Relation_Parser->completeDefinition()
.../Doctrine/Relation/Parser.php:196
1.0948 24185448 21. Doctrine_Relation_Parser->getImpl()
.../Doctrine/Relation/Parser.php:393
1.0948 24185448 22. Doctrine_Connection->getTable()
.../Doctrine/Relation/Parser.php:266
1.0949 24186876 23. Doctrine_Table->__construct()
.../Doctrine/Connection.php:1114
1.0949 24187884 24. Doctrine_Table->initDefinition()
.../Doctrine/Table.php:228
}}}
FYI: getRelations() is called on the Tree table and returns the only
relation "Fruit". Then Doctrine tries to completeDefinition() Fruit and in
the end tries to instantiate Fruit in FruitTable->initDefinition().
--
Ticket URL: <http://trac.doctrine-project.org/ticket/1412>
Doctrine <http://www.phpdoctrine.org>
PHP Doctrine Object Relational Mapper
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"doctrine-svn" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.co.uk/group/doctrine-svn?hl=en-GB
-~----------~----~----~----~------~----~------~--~---