On 8/28/06, Michal <[EMAIL PROTECTED]> wrote:

I suppose, that I get one objects, which accomplish all given parameters.
But I get list of two (first match condition day='th' and
timeinterval=t2, second match day='th' and timeinterval=t3).
Is there any way to write query, which will fetch from DB only "d2"
(object which accomplish all given filter parameters -- something like
day='th' and "one-timeinterval"=t2 and "next-timeinterval"=t3)?

If I understand you correctly, you are looking to construct a query for all Date objects  that have exactly 2 related time intervals (t2 and t3) which also have day=th; that is, a query something like:

Date.objects.filter(day='th', timeintervals__eq=[t2,t3])

However, Django does _not_ support queries of this type.

This is a consequence of the underlying SQL that the query represents. The __in comparison allows a list of values because SQL allows a query to test if a row belongs to a set. However, the __eq comparison does not allow comparison of sets, because the underlying SQL operation only allows comparison of values.

An SQL query that describes your requirements is not easy to compose, as SQL is ultimately restricted to comparisons performed on individual rows. I suspect you may need to hand-roll some SQL to achieve the query results you are seeking.

Yours,
Russ Magee %-)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to