Noticed a few things that need fixing, and didn't want to kill kittens in #885014: Add pager and tablesort to EntityFieldQuery, so here it goes.
1) field_attach_create_bundle() is called with the params reversed.
field_attach_create_bundle('bundle1', 'test_entity_bundle_key');
field_attach_create_bundle('bundle2', 'test_entity_bundle_key');
field_attach_create_bundle('test_bundle', 'test_entity');
Here we pass it $bundle, $entity_type, but it should be in reverse ($entity_type, $bundle)
2) The ordering methods sometimes get 'ASC' and 'DESC', and sometimes 'asc' and 'desc'. Since the core default is uppercase, it should be the same here.
3) We create entities for the "test_entity_bundle_key" entity type, which has two bundles: bundle1 and bundle2.
Those entities have values in a sample field, but that field is only attached to bundle1 and not bundle2.
This makes it impossible to test ordering by bundle if the query goes through field storage.
So two of the tests I added in #902830: EntityFieldQuery: field_sql_storage can't handle entityOrderBy (fatal error) look kinda silly because they test ordering by bundle, but the bundle is the same for each entry.
I will also need this for the tablesort integration tests.
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | 907760.patch | 11.94 KB | bojanz |
| #1 | 907760.patch | 10.32 KB | bojanz |
Comments
Comment #1
bojanz commentedHere's a patch.
Comment #2
chx commentedNote: field_attach_create_bundle in core does particularly nothing :) so it's no wonder the param swap went undetected.
Comment #3
bojanz commentedYeah, I've noticed, that's why it's in the "misc" patch ;)
Comment #5
bojanz commented#1: 907760.patch queued for re-testing.
EDIT: And...green.
Comment #6
chx commentedThis cleanup makes sense. We have verified together that no specific filtering functionality gets lost with these changes, the fltering is like greater than zero in all cases, the specific filter tests are not affected.
Comment #7
bojanz commentedOur conversation on IRC got me thinking.
Sure, this patch doesn't make the tests less precise. But are they as precise as they can be?
I went through the code once again and found a case (4 tests) which could be better.
In this case, even if the entityOrderBy call doesn't work, the propertyOrderBy will order things well enough for the tests to succeed. Let's make that better while we're at it.
Edit: So I fixed the tests, and found that the last two (field storage ones) are failing.
Debugged the query, and it turns out that the query is first ordered by property ftid, and then by the bundle, which means that it doesn't get ordered by bundle at all. This is because field storage adds the orderings in a different order than propertyQuery.
Comment #9
bojanz commentedAttaching a patch with the first two tests mentioned above fixed.
The other two are indicative of a larger problem, so I didn't touch them. Will be handled in #908798: EntityFieldQuery does not handle ordering correctly.
Let's get this one in.
Comment #10
chx commentedThanks for the extreme through work!
Comment #11
webchickGreat work! Committed to HEAD.