Ticket #1124 (closed defect: fixed)
Magic finder methods fail for aliased columns
| Reported by: | berdahl | Owned by: | romanb |
|---|---|---|---|
| Priority: | major | Milestone: | |
| Component: | Query/Hydration | Version: | 0.11.0 |
| Severity: | Keywords: | ||
| Cc: | Has Test: | yes | |
| Status: | Pending Core Response | Has Patch: | no |
Description
If a record declares columns that are aliased, those columns will not work with magic finders. For example, a record that contains a column declaration like…
$this->hasColumn('column_name as aliasedColumnName', 'integer', 4);
…should be findable using a magic finder like…
$record = $table->findOneByAliasedColumnName(4);
When this is attempted using doctrine 0.11rc3, one observes an exception thrown from deep inside doctine. See the attached unit test case to demonstrate various cases that should run, as written, but fail when run added to the set of unit tests run by automated test runs.
Code inspection suggests that the fundamental failure is in Doctrine_Table::call, which calls Doctrine_Inflector::tableize on the string extracted from the magic function (i.e. removing the 'findOneBy' or 'findBy' prefix) and treats the tableized result as a field name.