#19837: Regression in QuerySet.exclude and many to many ----------------------------------------------+-------------------- Reporter: timo | Owner: nobody Type: Bug | Status: new Component: Database layer (models, ORM) | Version: master Severity: Normal | Keywords: Triage Stage: Unreviewed | Has patch: 0 Easy pickings: 0 | UI/UX: 0 ----------------------------------------------+-------------------- The refactorings in #10790 appears to have cause an issue with QuerySet.exclude and many to many fields.
Attached is a regression test which demonstrates the problem. The test passes using checkout f811649710fb51e48217e9a78991735977decfd8, but fails against the next changeset (the ticket I mentioned above) through master. In the SQL query from the test, you can see that the "WHERE NOT" clause compares program IDs to a subquery that retrieves identifier IDs: {{{queries_program"."id" IN (SELECT U1."identifier_id}}} {{{ SELECT "queries_identifier"."id", "queries_identifier"."name" FROM "queries_identifier" LEFT OUTER JOIN "queries_program" ON ( "queries_identifier"."id" = "queries_program"."identifier_id" ) WHERE NOT (( "queries_program"."id" IN ( SELECT U1."identifier_id" FROM "queries_program" U1 INNER JOIN "queries_channel_programs" U2 ON (U1."id" = U2."program_id") WHERE (U2."channel_id" = 1 AND U1."identifier_id" IS NOT NULL) ) AND NOT ("queries_program"."identifier_id" IS NULL) AND "queries_program"."id" IS NOT NULL AND "queries_program"."id" IS NOT NULL )) ORDER BY "queries_identifier"."name" ASC }}} -- Ticket URL: <https://code.djangoproject.com/ticket/19837> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.