Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
database system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
9 Mar 2009 at 18:02 UTC
Updated:
3 Jan 2014 at 00:07 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
jcfiala commentedTagging issue.
Comment #2
csevb10 commentedMoving the bulk of the code from the execute to the setHeader will have the desired affect:
Until the header is set, you can't actually add the sorting information to the query, so you can't apply any of the sorting until at _least_ this point in the chain. This seems to be a reasonable place, then, to insert the orderBy execution, but I'm open to hear what other people think, too.
Comment #3
jcfiala commentedI'm rerolling the patch to include a test that makes sure that this functionality works - with the change to tablesort removed, it breaks, adding the changes fixes.
Comment #5
damien tournoud commentedI would rather override the behavior of orderBy() on TableSort, so that order by set after the extension are "queued" locally, and added to the end of the query at execute() time. Does putting this logic in setHeader() really makes sense?
Comment #6
chx commentedComment #7
jcfiala commentedI think it does, because doing it this way makes setHeader() work as a specialized orderBy - if I want to sort by sticky, header, and then created - which is what Forums wants to do and the cause of this ticket - then I just do:
$query->orderBy('sticky')->setHeader()->orderBy('created') - and the setHeader works just like the other orderBy() functions. It doesn't seem to make sense to me to make orderBy() work in one way if you're using setHeader and a different way if you're not.
Comment #8
damien tournoud commentedIn that case, you will have to rename setHeader() to something like orderByHeader()?
Comment #9
csevb10 commentedI feel like orderByHeader is more indicative of the true nature of the function with this change, so I'd vote for a change to orderByHeader despite the subsequent cleanup required on existing instances of setHeader.
Comment #10
jcfiala commentedI agree that this sounds like a much more reasonable change - I'll look into how often setHeader() is being used right now - better to change it now than later, most likely.
Comment #11
Crell commentedThere should only be 3-4 uses so far, I think. It's only been around about 3 weeks. :-)
I'm open to changing the name, although Damien's concept of a "smarter orderBy queue" is interesting as well. I guess I don't have a strong preference there until I see code for what Damien's would look like.
Comment #12
berdirI think the name change makes sense, in two ways:
- it indicates that the method is chainable (it was already before, but all other set* and add* functions are not).
- with the changed name, it also makes sense to have the logic there.. imho.
Re-rolled ch'x patch with the name change.
Comment #13
berdirComment #15
berdirThe tests failed because tracker.module is currently broken, moving the logic to orderByHeader just revealed that. Applied the same fix as DamZ has done in #394582-4: DBTNG: Tracker module
Comment #16
berdirComment #17
dries commentedI also support the name change. It always found setHeader() a strange name, and orderByHeader() makes it a bit more clear. The word "header" is still a bit odd for those not in the know.
I'm undecided about the two approaches though -- I'm asking Crell to make that call. The order by queue seems a bit more exotic. Would be good to see an example of how DamZ's syntax would be used (without actual implementation) to solve the forum problem.
Comment #18
Crell commentedI can see how the original proposal would work, but I'm not sure I follow DamZ's. DamZ, can you provide a code snippet or pseudocode or something so we can see what you mean?
Comment #20
berdirRe-roll with the new setHeader() calls renamed. Still needs DamZ's input...
Comment #22
berdirRe-rolled with more setHeader -> orderByHeader conversions..
Comment #24
berdirRe-rolled with more setHeader -> orderByHeader conversions..
Comment #25
damien tournoud commentedI was sure I posted something here already. The basic idea in #5 was to allow the query write to use:
The orderBy() before the extension are set in the main query object, but the orderBy after the extension are queued locally in the TableSort object, and only pushed to the main query object on execute().
Comment #26
damien tournoud commentedThinking about it, there is not much to gain from that. With the rename, the new function behavior is perfectly ok.
Let's get this in, and move to more DB:TNG conversion awesomeness.
Comment #27
dries commentedGreat, thanks. Committed to CVS -- nice clean-up and fix!