Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
field system
Priority:
Major
Category:
Bug report
Assigned:
Reporter:
Created:
11 Sep 2010 at 19:19 UTC
Updated:
20 Oct 2010 at 14:00 UTC
Jump to comment: Most recent file
Spin-off from #907760: EntityFieldQuery tests cleanup.
We have three ordering methods: propertyOrder, entityOrder, fieldOrder.
The problem shows itself when using more than one method.
The orderings are not added to the SelectQuery in the order in which they are defined, which leads to unexpected behaviour.
It can't be the same if I order by a field first, and then by a property second, and the other way around.
We need to fix entity.inc and field_sql_storage. Already discussed it with chx and should have a patch ready in the next 48h.
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | 908798.patch | 13.83 KB | bojanz |
| #8 | 908798.patch | 12.93 KB | bojanz |
| #6 | 908798.patch | 12.94 KB | bojanz |
| #5 | 908798.patch | 12.93 KB | bojanz |
| #2 | 908798.patch | 10.74 KB | bojanz |
Comments
Comment #1
chx commentedWe need to yank entityOrder, fieldOrder, propertyOrder and add one order, it will be a list of ('type' => $type, 'specifier' => something, direction' => ASC) where $type can be entity, property, field and specifier will be the respective name / for field a list of the field and the column name. We need to keep a fieldIndex going. The fields array will become sparse (ie it wontbe indexed from 0...count-1 but it will 0,1 , 5, 9 as it needs to be the same index as the order array which contains nonfield things) but who cares?
Comment #2
bojanz commentedFinally found some Drupal time.
Here's a patch. I want to add some more tests, but functionality wise it is done.
Comment #3
bojanz commentedThis is no longer valid, and will be replaced on reroll with "Save the index used for the new field, for later use in field storage".
Comment #4
chx commentedI know
+ foreach ($this->propertyConditions as $entity_condition) {is from HEAD but care to fix it? it reads really WTFish. You can change+ $index = $specifier['index']; $table_alias = $table_aliases[$index];into just$table_alias = $table_aliases[$specifier['index']]. thanks for the great work. Are you sure there is no need for new tests?Comment #5
bojanz commentedFixed.
And of course there's a need for new tests :) I said in #2 "I want to add some more tests". So yay, tests!
I added two more tests. We now have the following test combinations for multiple orderings:
1) propertyOrder + entityOrder in propertyQuery
2) propertyOrder + entityOrder in field storage
3) entityOrder + fieldOrder in field storage
I think this is enough. I can always add a fourth combination, propertyOrder + fieldOrder, but I think it's enough that all three variants are tested in a multiple-order scenario.
Comment #6
bojanz commentedForgot ending dots in a few test descriptions.
This should be the last one.
Comment #7
chx commentedThis is quite a find and quite a fix. We are getting closer to tablesort. A lot closer because we can ask the users to give us tablesort arrays in the form order stores them (almost).
Comment #8
bojanz commentedOops, had a coding standard violation. Let's pretend that never happened.
Replaced two "else if" occurrences with "elseif".
Still RTBC.
Comment #9
chx commentedNote that once this is committed we have #885014: Add pager and tablesort to EntityFieldQuery ready too.
Comment #10
sunTrailing white-space here.
Powered by Dreditor.
Comment #11
dries commentedLet's get that fixed quickly then. :)
Comment #12
bojanz commentedFixed.
Comment #13
dries commentedCommitted to CVS HEAD. Thanks.