Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
database system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
22 Dec 2010 at 22:45 UTC
Updated:
3 Jan 2014 at 02:41 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
solotandem commentedThe attached 1-line patch seems to fix the problem.
Comment #2
damien tournoud commentedew. That looks right, but that means we need more tests :(
Comment #3
solotandem commentedSimplified 1-line patch with revised test.
Comment #5
solotandem commentedWho knew this was a duplicate of #1003860: Count query fails to remove fields and expressions? This 1-line patch is: 1) cleaner than what was committed on that issue (it eliminates a redundant function call), 2) the test more fully tests the count query code by adding an order by clause, and 3) the test has a comment explaining the reason to have a column alias in the test. Posting rerolled patch here instead of reopening the other issue.
Comment #6
Crell commentedAs I noted in the issue linked in #5, the existence of drupal_map_assoc() inside SelectQuery is a critical bug as far as I'm concerned. If we need that functionality then inline it. It's not a complicated algorithm. Although I'm not entirely clear at the moment why we need to do that in the first place...
Comment #7
solotandem commentedThis revised 2-line patch removes the Drupal core function call and makes the groupBy() array an associative one so the count query code will work as "intended." With this change, both the group and order arrays are associative.
Comment #8
solotandem commentedComment #9
Crell commentedThat looks much better to me. The additions to the unit test have me confused, though. Isn't the point of that test to make sure that the countQuery() method works? Will it still be a valid test if we're adding the COUNT() statement manually?
Comment #10
solotandem commentedThe example:
- tests the removal of expressions from the count query (when a column alias is present) (so the function could be SUM, COUNT, MIN, MAX, etc.)
- is a real life example for a form or view that displays counts of grouped items and uses a pager (possibly it should include its own count query in this case)
Comment #11
Crell commentedAh, gotcha. In that case...
Comment #12
webchickGreat, thanks for the clean up and the additional test!
Committed to HEAD.