Ticket #1341 (closed defect: fixed)
Problem with relations & column aliases
| Reported by: | ishtanzar | Owned by: | romanb |
|---|---|---|---|
| Priority: | minor | Milestone: | 1.0.4 |
| Component: | Query/Hydration | Version: | 1.0.0 |
| Severity: | Keywords: | relation, alias, column | |
| Cc: | Has Test: | no | |
| Status: | Pending Core Response | Has Patch: | no |
Description
From this discussion.
When using the attached classes with this code :
Doctrine_Query::create()
->from("Episode ep")
->leftJoin("ep.team t")
->execute();
Gives the following exception :
Fatal error: Uncaught exception 'Doctrine_Record_Exception' with message 'Unknown property team_teamId' in /Users/ishtanzar/Sites/_library/Doctrine-0.11.1/Doctrine/Record.php:813
Stack trace:
#0 /Users/ishtanzar/Sites/_library/Doctrine-0.11.1/Doctrine/Record.php(1021): Doctrine_Record->rawGet('team_teamId')
#1 /Users/ishtanzar/Sites/_library/Doctrine-0.11.1/Doctrine/Record.php(949): Doctrine_Record->coreSetRelated('team', Object(Team))
#2 /Users/ishtanzar/Sites/_library/Doctrine-0.11.1/Doctrine/Access.php(133): Doctrine_Record->set('team', Object(Team))
#3 /Users/ishtanzar/Sites/_library/Doctrine-0.11.1/Doctrine/Hydrator.php(225): Doctrine_Access->offsetSet('team', Object(Team))
#4 /Users/ishtanzar/Sites/_library/Doctrine-0.11.1/Doctrine/Query/Abstract.php(999): Doctrine_Hydrator->hydrateResultSet(Object(PDOStatement), Array)
#5 /Users/ishtanzar/Sites/test/testDoctrineRelations/index.php(16): Doctrine_Query_Abstract->execute()
#6 {main}
thrown in /Users/ishtanzar/Sites/_library/Doctrine-0.11.1/Doctrine/Record.php on line 813
From romanb :
all column names (not aliases) are forced to lowercase in doctrine for portability. That is, if you do: hasColumn('team_teamId as id') doctrine stores: column name = team_teamid , column alias (field name) = id. And it looks like the relation mapping does not force the given name to lowercase before looking it up, maybe it should.
Attachments
Change History
Note: See
TracTickets for help on using
tickets.