#17930: Error in Queryset with operator | (union queryset) + slice
----------------------------------------------+----------------------------
Reporter: vini.gracindo@… | Owner: nobody
Type: Bug | Status: new
Component: Database layer (models, ORM) | Version: 1.3
Severity: Normal | Keywords: queryset
Triage Stage: Unreviewed | union, slice
Easy pickings: 0 | Has patch: 0
| UI/UX: 0
----------------------------------------------+----------------------------
{{{
class Example:
name = models.CharField(max_length = 30)
public = models.BooleanField()
}}}
>>> Example.objects.create('example 1', False)
<Example: Example object>
>>> Example.objects.create('example 2', False)
<Example: Example object>
>>> Example.objects.create('example 3', True)
<Example: Example object>
>>> Example.objects.create('example 4', True)
<Example: Example object>
>>> Example.objects.create('example 5', False)
<Example: Example object>
>>> query = Example.objects.filter(public = True)
>>> if(query.count() < 3):
... query = query | Example.objects.filter(public =
False).order_by('?')[:1]
...
>>> query.count()
5
>>>
When using the union of querysets to slice it "ignores" the slice and
takes all objects where public = false.
--
Ticket URL: <https://code.djangoproject.com/ticket/17930>
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 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-updates?hl=en.