[Django] #32882: Problems when comparing two fields with None value using F() in Case()

4 views
Skip to first unread message

Django

unread,
Jun 25, 2021, 9:24:45 AM6/25/21
to django-...@googlegroups.com
#32882: Problems when comparing two fields with None value using F() in Case()
-------------------------------------+-------------------------------------
Reporter: jntsouza | Owner: nobody
Type: Bug | Status: new
Component: Database | Version: 2.2
layer (models, ORM) | Keywords: F() Case() None !=
Severity: Normal | None
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Problems when comparing two fields in an annotate.

when = ~Q(**{ 'name' :
F('order_process__name') })

annotate = {
'has_name_divergence': Case(
When(when, then=True),
default=False,
output_field=CharField(),
),
}

When both fields have None value, the case result is true.
None != None
Using postgresSQL

--
Ticket URL: <https://code.djangoproject.com/ticket/32882>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jun 28, 2021, 12:57:23 AM6/28/21
to django-...@googlegroups.com
#32882: Problems when comparing two fields with None value using F() in Case()
-------------------------------------+-------------------------------------
Reporter: Jonathan Souza | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: 2.2
(models, ORM) |
Severity: Normal | Resolution: duplicate
Keywords: F() Case() None != | Triage Stage:
None | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => duplicate


Old description:

> Problems when comparing two fields in an annotate.
>
> when = ~Q(**{ 'name' :
> F('order_process__name') })
>
> annotate = {
> 'has_name_divergence': Case(
> When(when, then=True),
> default=False,
> output_field=CharField(),
> ),
> }
>
> When both fields have None value, the case result is true.
> None != None
> Using postgresSQL

New description:

Problems when comparing two fields in an annotate.
{{{
when = ~Q(**{ 'name' :
F('order_process__name') })

annotate = {
'has_name_divergence': Case(
When(when, then=True),
default=False,
output_field=CharField(),
),
}
}}}
When both fields have None value, the case result is true.
`None != None`
Using postgresSQL

--

Comment:

Duplicate of #29291.

> `None != None`. Using PostgreSQL.

`NULL` is not comparable.

--
Ticket URL: <https://code.djangoproject.com/ticket/32882#comment:1>

Reply all
Reply to author
Forward
0 new messages