Closed (fixed)
Project:
Party
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
20 Sep 2012 at 12:33 UTC
Updated:
24 Jan 2013 at 13:00 UTC
Jump to comment: Most recent file
At the moment it's hardcoded into PartyQuery that the party table is unaliased and called 'party', for example:
//This Will Work
$query = db_select('party')
->extend('PartyQuery')
->fieldCondition(...)
.
.
->execute();
// This won't work
$query = db_select('party', 'p')
->extend('PartyQuery')
->fieldCondition(...)
.
.
->execute();
Is it possible to sniff out the Alias in the query Extender constructor?
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 1790252-6-allow_any_base_alias.patch | 2.63 KB | andrewbelcher |
| #4 | 1790252-4-allow_any_base_alias.patch | 2.63 KB | andrewbelcher |
Comments
Comment #1
andrewbelcher commentedFYI, there is a helper method for building party queries:
This is what
party_query()does:But yes, it would be good to be able to make the extender handle different aliases for the party table. Not sure if this can be magically sniffed or if we need to be able to pass an option to the constructor (or both). I'll look into it later.
Comment #2
joachim commentedYou can get a list of tables (and their aliases I think) from the query object.
Comment #3
andrewbelcher commentedYes, so it will be easy to sniff out in a simpe query. The more complicated issue is that it will need to still work if you have a query where you join to the party table twice, we wont know which one to use.
I think probably what we want to do it make it attempt to sniff it out automatically and just select the first one. Then we need to provide a method to explicitly set which table we're working from. This then means we can deal with the situation where you're doing something more complicated. We then need to namespace our joins so that we don't get two different parties confused.
I think all of that will be relatively simple, so when I get some time I'll give it a go!
Comment #4
andrewbelcher commentedHere is a possible patch.
It attempts to sniff out the table in the constructor and provides a method to get/set the base alias.
Comment #6
andrewbelcher commentedNeeded re-basing after some other changes...
Comment #7
rlmumfordThanks for all your work on this andrewbelcher, it's an excellent feature.
Comment #8.0
(not verified) commentedUpdated issue summary.