I've been writing some tests for #885014: Add pager and tablesort to EntityFieldQuery, and this example gave me a fatal error (undefined method EntityFieldQuery::orderBy in field_sql_storage.module):
$query = new EntityFieldQuery();
$query->fieldCondition($this->fields[0], 'value', 2, '>');
$query->entityOrderBy('entity_id', 'asc');
$query->execute();
What's the problem?
field_sql_storage_field_storage_query() has the following code:
foreach ($query->entityOrder as $key => $direction) {
$sql_field = $key == 'entity_type' ? 'fcet.type' : "$field_base_table.$key";
$query->orderBy($sql_field, $direction);
}
return $query->finishQuery($select_query, $id_key);
$query is EntityFieldQuery here, we need $select_query instead.
Comments
Comment #1
bojanz commentedHere's a patch. Let me know if it deserves a test, and I'll add one.
Comment #2
chx commentedComment #3
bojanz commentedTests
I basically duplicated the existing ones for sorting, but with a fieldCondition (and modified expectations of course).
This way we have the same coverage for the two different code paths.
Comment #4
chx commentedMore tests and a bugfix, that's awesome (if the tests pass).
Comment #5
dries commentedCommitted to CVS HEAD. Thanks.