DB API and Model Interface don't agree on meaning of None
|Reported by:||Owned by:||Adrian Holovaty|
|Component:||Database layer (models, ORM)||Version:||master|
|Severity:||normal||Keywords:||exclude filter qs-rf-fixed|
|Cc:||mir@…, django@…||Triage Stage:||Accepted|
|Has patch:||yes||Needs documentation:||yes|
|Needs tests:||yes||Patch needs improvement:||no|
When the value of a field in a model is None it corresponds to a NULL item in the database.
However, when using filter() or exclude() you can't pass
does nothing, while
generates invalid SQL.
I know the preferred way to test for NULL is with
__isnull, but the code above is what I tried first.
I would like it if
my_field=None is treated as equivalent to
my_field__isnull=True (a naive patch is attached)
but if not, then at least there should be a useful error raised when you try something like
Change History (20)
comment:8 Changed 9 years ago by
|Status:||closed → reopened|
|Triage Stage:||Unreviewed → Accepted|