UnionOfRAD/lithium — Issue #339: Mysql: fails with an ORDER BY on related data
Author: marcghorayeb
Created: 2012-02-17 09:54:19+00:00
State: open

Hello,

```'order' => array('Related.field' => 'ASC')```

This fails in a mysql database, where Related is the name of the relationship in the current model.
I tracked it to line 834 in source/Database.php. It checks the existence of the field in the schema of the current model, and since that field does not exist in the model per say, the ORDER BY returned is empty and a PDOException is thrown.

I see two solution:
- Add an empty schema field as done inside the ```conditions``` method of Database.
- Change the schema returned to take into account relationships of a query and populate it accordingly.

Right now, a hack is to type the ```order``` parameter as a string.

Any thoughts? The framework is coming along nicely but I feel Mysql relationships are lagging a little behind, i'd gladly help if I could understand a little bit more the vision of the team on the sql adapters :)