|previous : next|
This documentation is for the unreleased development version of jOOQ. Click on the above version links to get this documentation for a supported version of jOOQ.
Merge CASE .. WHEN and ELSE clauses
Applies to ✅ Open Source Edition ✅ Express Edition ✅ Professional Edition ✅ Enterprise Edition
When a searched CASE expression's last
WHEN clause returns the same value as the
ELSE clause, then the
WHEN clause is redundant. If it's the only
WHEN clause, then the entire
CASE exression is redundant.
Using Settings.transformPatternsCaseMergeWhenElse, the following transformations can be achieved:
-- With Settings.transformPatternsCaseMergeWhenElse active, this: SELECT CASE WHEN a = b THEN x WHEN c = d THEN y ELSE y END, CASE WHEN a = b THEN x ELSE x END FROM tab; -- ... is transformed into the equivalent expression: SELECT CASE WHEN a = b THEN x ELSE y END, x FROM tab;