Opened 6 years ago
Closed 6 years ago
#29710 closed New feature (wontfix)
Support simple-style CASE expressions
Reported by: | Tom Forbes | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Mariusz Felisiak | Triage Stage: | Unreviewed |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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)
Change History (4)
comment:1 by , 6 years ago
comment:2 by , 6 years ago
Type: | Uncategorized → New feature |
---|
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.
comment:3 by , 6 years ago
Cc: | added |
---|
comment:4 by , 6 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
Let's close, until more compelling arguments are provided to implement this.
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.