Opened 3 years ago

Last modified 3 years ago

#16893 new Bug

negation of Q object returns the same thing

Reported by: morgy.wahl@… Owned by: nobody
Component: Database layer (models, ORM) Version: 1.2
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by aaugustin)

Not sure if this is a bug.

I was attempt to construct a Q object that wouldn't ever match anything (an API calls for a Q object to be returned, but certain situations call for nothing to be matched by it). I initially figured ~ Q() would do the trick, but that matches everything, just like a plain Q().

(I ended up using Q(pk__isnull=True), which is a hack but seems to be OK.)

Change History (3)

comment:1 follow-up: Changed 3 years ago by aaugustin

  • Description modified (diff)
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Fixed formatting (you can use "preview" before submitting a ticket).

comment:2 in reply to: ↑ 1 Changed 3 years ago by morgy.wahl@…

Replying to aaugustin:

Fixed formatting (you can use "preview" before submitting a ticket).

Thanks.

comment:3 Changed 3 years ago by carljm

  • Triage Stage changed from Unreviewed to Accepted

Haven't dug into what would be required to make this work, but presuming it can be reasonably implemented this seems sensible.

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