Opened 17 years ago
Closed 17 years ago
#7111 closed (fixed)
Double negation in sql query fails on Oracle
Reported by: | Erin Kelly | Owned by: | Erin Kelly |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Keywords: | oracle | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
In [3]: qs = Item.objects.exclude(~Q(tags__name='t1', name='one')) In [4]: qs.query.as_sql() Out[4]: ('SELECT "TEST_ITEM"."ID", "TEST_ITEM"."NAME", "TEST_ITEM"."CREATED", "TEST_ITEM"."CREATOR_ID", "TEST_ITEM"."NOTE_ID" FROM "TEST_ITEM" INNER JOIN "TEST_NOTE" ON ("TEST_ITEM"."NOTE_ID" = "TEST_NOTE"."ID") WHERE NOT NOT ("TEST_ITEM"."NAME" = %s AND "TEST_ITEM"."ID" IN (SELECT "TEST_ITEM_TAGS"."ITEM_ID" FROM "TEST_ITEM_TAGS" INNER JOIN "TEST_TAG" ON ("TEST_ITEM_TAGS"."TAG_ID" = "TEST_TAG"."ID") WHERE "TEST_TAG"."NAME" = %s )) ORDER BY "TEST_NOTE"."NOTE" DESC, "TEST_ITEM"."NAME" ASC', ('one', 't1'))
This causes an error in Oracle because the "NOT NOT (condition)" syntax in the where clause is invalid. The syntax "NOT (NOT (condition))" would work.
Change History (3)
comment:1 by , 17 years ago
comment:2 by , 17 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:3 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Note:
See TracTickets
for help on using tickets.
By the way, this query is lifted straight from the
queries
test.