Opened 16 years ago

Closed 16 years ago

Last modified 16 years ago

#6065 closed (invalid)

Field Lookup - notin

Reported by: RichardH <Richard.House@…> 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)

sql_notin.patch (1.7 KB ) - added by RichardH <Richard.House@…> 16 years ago.
Patch for implementing NOTIN

Download all attachments as: .zip

Change History (3)

by RichardH <Richard.House@…>, 16 years ago

Attachment: sql_notin.patch added

Patch for implementing NOTIN

comment:1 by James Bennett, 16 years ago

Resolution: invalid
Status: newclosed

This is what exclude() is for; otherwise every database lookup operator would need a corresponding "not" version.

comment:2 by RichardH <Richard.House@…>, 16 years ago

Thanks. The pointer to exclude()has provided me with enlightenment :)
Richard

Note: See TracTickets for help on using tickets.
Back to Top