Changes between Initial Version and Version 1 of Ticket #37470


Ignore:
Timestamp:
Nov 3, 2026, 1:45:25 AM (98 minutes ago)
Author:
maiload
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #37470 – Description

    initial v1  
    3131
    3232{{{#!python
     33from django.db.models import BooleanField, ExpressionWrapper, Q
     34
     35always_false = ~ExpressionWrapper(~Q(pk__in=[]), output_field=BooleanField())
     36Item.objects.filter(always_false)            # Expected: no rows. Actual: all rows.
     37Item.objects.annotate(x=always_false)        # Expected: x=False. Actual: x=True.
     38}}}
     39
     40{{{#!python
    3341always_false = ~ExpressionWrapper(~Q(pk__in=[]), output_field=BooleanField())
    3442Item.objects.filter(always_false)            # Expected: no rows. Actual: all rows.
    … …  
    4048Adding an `except FullResultSet: raise EmptyResultSet` branch to `NegatedExpression.as_sql()` fixes it: the reproduction tests pass and the full test suite passes on SQLite with that change. I haven't tested other backends yet. I'd like to submit a PR with a regression test.
    4149
    42 With this change the reproduction tests pass and the full test suite passes on SQLite. I haven't tested other backends yet.
    43 
    4450Reproduced on main (b501b8493f) with SQLite.
    4551
Back to Top