#6065 closed (invalid)
Field Lookup - notin
| Reported by: | Owned by: | nobody | |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | dev |
| Severity: | Keywords: | NOT IN | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Field Lookups include IN which is the SQL equivalent of:
SELECT ... WHERE id IN (1, 3, 4);
The docs example is:
Entry.objects.filter(id__in=[1, 3, 4])
However, there is no Field lookup for the SQL equivalent of:
SELECT ... WHERE id NOT IN (1, 3, 4);
The attached patch implements NOTIN shown in the example:
Entry.objects.filter(id__notin=[1, 3, 4])
It works on sqlite, but I haven't tested it extensively. Someone with more than my limited understanding of the db code needs to look for possible implications.
Attachments (1)
Change History (3)
by , 18 years ago
| Attachment: | sql_notin.patch added |
|---|
comment:1 by , 18 years ago
| Resolution: | → invalid |
|---|---|
| Status: | new → closed |
This is what exclude() is for; otherwise every database lookup operator would need a corresponding "not" version.
comment:2 by , 18 years ago
Thanks. The pointer to exclude()has provided me with enlightenment :)
Richard
Patch for implementing NOTIN