Opened 7 years ago
Last modified 7 years ago
#29932 closed Bug
Queryset `difference()` after `intersection()` returns wrong queryset on SQLite — at Initial Version
| Reported by: | michaeldel | Owned by: | nobody |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | 2.1 |
| Severity: | Normal | Keywords: | queryset sqlite difference intersection |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Considering a simple model
from django.db import models
class Foo(models.Model):
pass
Here is the minimal way to encounter this issue
Foo.objects.create(pk=1) Foo.objects.create(pk=2) a = Foo.objects.all() b = Foo.objects.intersection(Foo.objects.filter(pk=1)) assert a.count() == 2 assert b.count() == 1 diff = a.difference(b) assert diff.exists() == 1 # fails with SQLite!
This operation however works as expected on PostgreSQL.
Note:
See TracTickets
for help on using tickets.