Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#6065 closed (invalid)

Field Lookup - notin

Reported by: RichardH <Richard.House@…> Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Keywords: NOT IN
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


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@…> 7 years ago.
Patch for implementing NOTIN

Download all attachments as: .zip

Change History (3)

Changed 7 years ago by RichardH <Richard.House@…>

Patch for implementing NOTIN

comment:1 Changed 7 years ago by ubernostrum

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

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

comment:2 Changed 7 years ago by RichardH <Richard.House@…>

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

Add Comment

Modify Ticket

Change Properties
<Author field>
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.