Re: Adding UNION/INTERSECT/EXCEPT to the ORM

2017-01-12 Thread Florian Apolloner
Jupp, sounds good to me too -- will see that I get the PR updated this afternoon On Thursday, January 12, 2017 at 1:20:04 AM UTC+1, charettes wrote: > > +1 to QuerySet.difference() > > Le mercredi 11 janvier 2017 17:00:12 UTC-5, sebleier a écrit : >> >> We cannot use the name "QuerySet.except()"

Re: Adding UNION/INTERSECT/EXCEPT to the ORM

2017-01-11 Thread charettes
+1 to QuerySet.difference() Le mercredi 11 janvier 2017 17:00:12 UTC-5, sebleier a écrit : > > We cannot use the name "QuerySet.except()" since except is a reserved word >> in Python. Do you prefer minus() (as suggested by Florian), except_() (as >> done by SQLAlchemy), or something else? >> >>

Re: Adding UNION/INTERSECT/EXCEPT to the ORM

2017-01-11 Thread Sean Bleier
> > We cannot use the name "QuerySet.except()" since except is a reserved word > in Python. Do you prefer minus() (as suggested by Florian), except_() (as > done by SQLAlchemy), or something else? > > Can I suggest using "QuerySet.difference"? It's what python's sets use for achieving the same fu

Re: Adding UNION/INTERSECT/EXCEPT to the ORM

2017-01-11 Thread Tim Graham
We cannot use the name "QuerySet.except()" since except is a reserved word in Python. Do you prefer minus() (as suggested by Florian), except_() (as done by SQLAlchemy), or something else? On Monday, December 26, 2016 at 6:28:15 PM UTC-5, Adam Johnson wrote: > > Yes it's different, they cannot b

Re: Adding UNION/INTERSECT/EXCEPT to the ORM

2016-12-26 Thread Adam Johnson
Yes it's different, they cannot be changed due to backwards compatibility issues. They don't result in UNION in SQL, they union the filters on two querysets that are on the same exact model. On 26 December 2016 at 21:00, Cristiano Coelho wrote: > Is this going to be different from the pipe ( | )

Re: Adding UNION/INTERSECT/EXCEPT to the ORM

2016-12-26 Thread Cristiano Coelho
Is this going to be different from the pipe ( | ) and and ( & ) operators on querysets? If I'm not wrong those can already result in a union query (but not necessary, sometimes it just returns a query with an or/and condition) El viernes, 23 de diciembre de 2016, 11:12:40 (UTC-3), Florian Apoll

Re: Adding UNION/INTERSECT/EXCEPT to the ORM

2016-12-23 Thread Florian Apolloner
Ok, everything seems to be working so far, I'll try adding `is_allowed` over the next few days, then I can get rid of the extra `QuerySet` class. On Friday, December 23, 2016 at 3:12:40 PM UTC+1, Florian Apolloner wrote: > > Hi, > > I have a currently WIP PR at https://github.com/django/django/pu

Re: Adding UNION/INTERSECT/EXCEPT to the ORM

2016-12-23 Thread Florian Apolloner
Hi Simon, On Friday, December 23, 2016 at 3:27:46 PM UTC+1, charettes wrote: > > users = User.objects.values(name=F('username')) > groups = Group.objects.values('name') > > results = users.union(groups).distinct().order_by('name')[:10] > That does indeed work already, but it would be nice if it w

Re: Adding UNION/INTERSECT/EXCEPT to the ORM

2016-12-23 Thread charettes
Hey Florian! > How can I change the generated order_by clause to reference the columns "unqualified" (ie without table name), can I somehow just realias every column? Now that we have F() aliasing working in iterator() I would suggest to restrict all combined queries to have the same set on fi

Adding UNION/INTERSECT/EXCEPT to the ORM

2016-12-23 Thread Florian Apolloner
Hi, I have a currently WIP PR at https://github.com/django/django/pull/7727 The usage is currently something like this: qs1 = User.objects.all().values('username') qs2 = Group.objects.all().values('name') results = qs1.union(qs).distinct().order_by('name')[:10] (order_by does not work though ye