On Monday 08 May 2006 12:17, Michael Radziej wrote:
> Sorry for the long delay, your posting confused me about what I want
> ;-)
>
> My original intentions are completely different from Luke's. I really
> need a function that builds the union over any list (or any
> iterator). Perhaps an example helps:
>
> union([aModelInstance.related_set for aModelInstance in
> someFunction()])
>
> where someFunction is more or a less a kind of business rule that
> defines a data set.
>
> Luke's idea is really imlemented very easily, since QuerySet.union is
> the same as QuerySet.__or__. I really don't care much whether the
> underlying database engine does a OR or a UNION. Am I too naive here?
>
> Now, it's probably a bad idea to do it diffent from sets. Is then
> anyone still interested in my original proposal (like above) under a
> different name, or was it all just a misunderstanding?
Now I'm not sure either, looking back at the posts :-)
Some people (e.g. Joseph) were definitely thinking in terms of doing a
UNION or UNION ALL in SQL. For 'UNION', I think the ORM constrains you
to using a single model, and therefore a single table, in which case
'UNION' is equivalent to an 'OR', so for your use case, wouldn't this
suffice:
reduce(operator.or_, [aModelInstance.related_set
for aModelInstance in someFunction()])
For 'UNION ALL', however, it's different, and I think some functionality
to support that would be nice.
Luke
--
"I was sad because I had no shoes, until I met a man who had no feet.
So I said, "Got any shoes you're not using?" (Steven Wright)
Luke Plant || L.Plant.98 (at) cantab.net || http://lukeplant.me.uk/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-developers
-~----------~----~----~----~------~----~------~--~---