[Django] #29710: Support simple-style CASE expressions

4 views
Skip to first unread message

Django

unread,
Aug 25, 2018, 7:24:26 PM8/25/18
to django-...@googlegroups.com
#29710: Support simple-style CASE expressions
-------------------------------------+-------------------------------------
Reporter: Tom | Owner: nobody
Forbes |
Type: | Status: new
Uncategorized |
Component: Database | Version: master
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Currently we only support one variant of the SQL CASE statement:

{{{
CASE WHEN a = 1 THEN 'one' WHEN a = 2 THEN 'two' ELSE '?' END
}}}

There is a simpler version when you just need to do an exact check on a
single value:

{{{
CASE a WHEN 1 THEN 'one' WHEN 2 THEN 'two' ELSE '?' END
}}}

This may be easier for databases to optimize against, especially if you
are producing large statements with many cases
(https://code.djangoproject.com/ticket/23646)

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

Django

unread,
Aug 26, 2018, 10:32:39 AM8/26/18
to django-...@googlegroups.com
#29710: Support simple-style CASE expressions
-------------------------------------+-------------------------------------
Reporter: Tom Forbes | Owner: nobody
Type: Uncategorized | Status: new
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tom Forbes):

I did some benchmarking on MySQL and Postgres, and it seems the difference
between the two is negligible. This might not hold for all databases
however the work to add this might not be worth it.

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

Django

unread,
Aug 26, 2018, 11:52:05 AM8/26/18
to django-...@googlegroups.com
#29710: Support simple-style CASE expressions
-------------------------------------+-------------------------------------
Reporter: Tom Forbes | Owner: nobody
Type: New feature | Status: new

Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

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

* type: Uncategorized => New feature


Comment:

IMO it will not have a performance impact also on Oracle, that's why I
don't think it is worth adding this to the Django. Thanks for checking
this.

--
Ticket URL: <https://code.djangoproject.com/ticket/29710#comment:2>

Django

unread,
Aug 26, 2018, 11:55:48 AM8/26/18
to django-...@googlegroups.com
#29710: Support simple-style CASE expressions
-------------------------------------+-------------------------------------
Reporter: Tom Forbes | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

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

* cc: felixxm (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/29710#comment:3>

Django

unread,
Aug 27, 2018, 3:22:06 AM8/27/18
to django-...@googlegroups.com
#29710: Support simple-style CASE expressions
-------------------------------------+-------------------------------------
Reporter: Tom Forbes | Owner: nobody
Type: New feature | Status: closed

Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

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

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


Comment:

Let's close, until more compelling arguments are provided to implement
this.

--
Ticket URL: <https://code.djangoproject.com/ticket/29710#comment:4>

Reply all
Reply to author
Forward
0 new messages