{{{
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.
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>
* 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>
* cc: felixxm (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/29710#comment:3>
* 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>