#24525: AssertionError at `Query.change_aliases`
-------------------------------------+-------------------------------------
Reporter: coolRR | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.7
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by jarshwah):
Can you try your queryset out with django 1.8 please? I've tried to
emulate the idea by combining two querysets, one that has distinct
applied, and that behaviour is not allowed (in 1.8):
{{{
In [9]: Company.objects.filter(name='HI').distinct() &
Company.objects.exclude(name='HI')
---------------------------------------------------------------------------
AssertionError Traceback (most recent call
last)
<ipython-input-9-b0c9de44f4df> in <module>()
----> 1 Company.objects.filter(name='HI').distinct() &
Company.objects.exclude(name='HI')
/Users/smeatonj/Development/django/django/db/models/query.py in
__and__(self, other)
305 combined = self._clone()
306 combined._merge_known_related_objects(other)
--> 307 combined.query.combine(other.query, sql.AND)
308 return combined
309
/Users/smeatonj/Development/django/django/db/models/sql/query.py in
combine(self, rhs, connector)
494 "Cannot combine queries once a slice has been taken."
495 assert self.distinct == rhs.distinct, \
--> 496 "Cannot combine a unique query with a non-unique
query."
497 assert self.distinct_fields == rhs.distinct_fields, \
498 "Cannot combine queries with different distinct
fields."
AssertionError: Cannot combine a unique query with a non-unique query.
}}}
So if you hit the same problem as I did in 1.8, then there's little
motivation to try to investigate the cause of your original problem in 1.7
since it's explicitly disallowed in 1.8. I would venture that the reason
it's disallowed in 1.8 (assuming it was "valid" in 1.7) is for similar
reasons that you're seeing now.
The SQL dump provided above doesn't appear to show any distinct clauses,
but your original problem description did. We don't have enough
information here to figure out the problem.
If you could at least provide the stacktrace when the assert is hit, that
might help narrow it down. But, honestly, if this is important enough to
your application then you should spend the time needed to create a
reproducible series of steps. We help where we can, but I think you'd be
hard pressed to find someone willing to try combination after combination
trying to arrive at a similar situation that you're in because it'd take
you "too much time".
--
Ticket URL: <https://code.djangoproject.com/ticket/24525#comment:7>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/064.55ef9d92786b497185275fc133029df9%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.