Re: #28560 - distinct() on ordered queryset with restricted list of columns returns incorrect result

2020-10-30 Thread Adam Johnson
I misunderstood the bug, the blog post Fran linked to has cleared it up for me. I think option 3 makes sense now. On Thu, 29 Oct 2020 at 12:52, Michael Manfre wrote: > Having run in to this issue in the past, automatically changing the > meaning and/or breaking the query can turn in to a debug

Re: #28560 - distinct() on ordered queryset with restricted list of columns returns incorrect result

2020-10-29 Thread Michael Manfre
Having run in to this issue in the past, automatically changing the meaning and/or breaking the query can turn in to a debug time sink. Option 3 could save people a bit of time. Cheers, Michael Manfre On Wednesday, October 28, 2020 at 8:46:46 PM UTC-4 charettes wrote: > I'm also a fan of

Re: #28560 - distinct() on ordered queryset with restricted list of columns returns incorrect result

2020-10-28 Thread charettes
I'm also a fan of option 3. to require an explicit opt-in or raise an error. Not a lot of folks are familiar with this requirement imposed by the usage of DISTINCT and even if Model.Meta.ordering is the most common reason but unexpected ordering it can also be caused by the dynamic creation of

Re: #28560 - distinct() on ordered queryset with restricted list of columns returns incorrect result

2020-10-28 Thread Tobias McNulty
I tend to agree, though I'll note that was also a bug at one point: https://code.djangoproject.com/ticket/5321 On Wed, Oct 28, 2020 at 5:38 PM Fran Hrženjak wrote: > Personally I would prefer to get a ProgrammingError, so option 3. > > Explicit is better then implicit  > > Here is a great

Re: #28560 - distinct() on ordered queryset with restricted list of columns returns incorrect result

2020-10-28 Thread Fran Hrženjak
Personally I would prefer to get a ProgrammingError, so option 3. Explicit is better then implicit  Here is a great explanation of this exact issue, cleared it up for me: https://blog.jooq.org/2018/07/13/how-sql-distinct-and-order-by-are-related/ > On 28.10.2020., at 20:04, Tobias McNulty

Re: #28560 - distinct() on ordered queryset with restricted list of columns returns incorrect result

2020-10-28 Thread Tobias McNulty
On Wed, Oct 28, 2020 at 3:38 PM Adam Johnson wrote: > I’d vote for option 2. I don’t think it can be expected the ordering will > be obeyed when not selecting the columns it includes. > Thanks! To make sure I understand, are you suggesting we should leave the behavior with an explicit

Re: #28560 - distinct() on ordered queryset with restricted list of columns returns incorrect result

2020-10-28 Thread Adam Johnson
I’d vote for option 2. I don’t think it can be expected the ordering will be obeyed when not selecting the columns it includes. On Wed, 28 Oct 2020 at 19:03, Tobias McNulty wrote: > Hi all, > > Starting a thread on ticket #28560 > , "distinct() on

#28560 - distinct() on ordered queryset with restricted list of columns returns incorrect result

2020-10-28 Thread Tobias McNulty
Hi all, Starting a thread on ticket #28560 , "distinct() on ordered queryset with restricted list of columns returns incorrect result." In a nutshell: $ cat testapp/models.py from django.db import models class School(models.Model): name =