Re: Really complicated query (or not?)
Re: Really complicated query (or not?)
- Subject: Re: Really complicated query (or not?)
- From: Alexander Spohr <email@hidden>
- Date: Sun, 8 Jul 2007 15:31:25 +0200
Ah... i love those :)
You can not AND them, as one AP can not have property=x AND property=y.
Therefore you need to OR both qualifiers.
That brings the problem that you would get all Rs having either x or
y or (x and y), which you don’t want.
Now comes the tricky part: you need to add a GROUP BY HAVING COUNT =
2 to your qualifier. And maybe you should add a view that flattens
some of the relationships just to get a better angle at qualifying.
As I have no deeper insight to your model I am not sure what
attribute you should GROUP.
If you use PostgreSQL just include the extensions i mailed to the
list a while ago. They are pretty EOF-aware and don’t break any of
your code. I did not find the time to push them back to WOnder.
If you use another database you need to either inject the GROUP BY
somewhere, or you could fetch them all and filter in memory - whereas
the latter will be much slower and memory consuming.
atze
Am 08.07.2007 um 03:53 schrieb Miguel Arroz:
Hi!
I need to build a complex fetch spec to solve a weird problem.
Here's the part of the model that matters:
+-----+ +-----+ +------+ +------+
| R | <--->> | A | <--->> | AP | <<---> | QO |
+-----+ +-----+ +------+ +------+
^
^
|
|
V
+------+
| QP |
+------+
My goal it to count the Rs in a given situation (it's the same as
fetching them, but I'm using Wonder to count instead of fetch). And
the crieria I want is:
1) All Rs where I have an APs with aValue property = "x" and QO =
"qo" and QP = "qp".
2) All Rs where I have an APs with aValue property = "y" and QO =
"qo2" and QP = "qp2".
(each R will have only one AP for condition 1 and one AP for
condition 2)
I want to AND those two conditions. In practice, I have two sets
of APs, and I want the Rs' that are in both sets (the intersection
of Rs).
Also, I want to do this all in the same query. I'm talking about
huge numbers of objects, so I don't want to get all the PKs of the
APs, and then work with them in memory to obtain Rs.
Any ideia how to do this? I think the solution may be
ERXQualifierInSubquery, but I couldn't make it work (specially
because the "3 argument constructor" is actually a 4 argument
constructor...).
My problem is that making a qualifier for R with the format
"a.ap.qo = %@ and a.ap.qp = %@ and a.ap.aValue = %@" wouldn't work,
because I would not be selecting the same AP, right? I'm saying
that I want Rs with an AP with a certain QO, and an AP with a
certain QP but i'm not saying they MUST be the same.
Please please give me some hints, I really need to make this
work. If you want more details just ask, it's almost 3am here and
my mind is really confused with this.
Yours
Miguel Arroz
Miguel Arroz
http://www.terminalapp.net
http://www.ipragma.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40freeport.de
This email sent to email@hidden
Freeport & Soliversum
Alexander Spohr
email@hidden
www.freeport.de
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden