Available in versions: Dev (3.20) | Latest (3.19) | 3.18

This is experimental functionality, and as such subject to change. Use at your own risk!

CASE searched to CASE simple

Applies to ✅ Open Source Edition   ✅ Express Edition   ✅ Professional Edition   ✅ Enterprise Edition

A searched CASE expression can be simplified into a simple CASE expression, if it always equality compares the same expression.

Using Settings.transformPatternsCaseSearchedToCaseSimple, the following transformations can be achieved:

-- With Settings.transformPatternsCaseSearchedToCaseSimple active, this:
SELECT
  CASE WHEN a = b THEN 1 END,
  CASE WHEN a = b THEN 1 WHEN a = c THEN 2 ELSE 3 END
FROM tab;

-- ... is transformed into the equivalent expression:
SELECT
  CASE a WHEN b THEN 1 END,
  CASE a WHEN b THEN 1 WHEN c THEN 2 ELSE 3 END
FROM tab;

References to this page

Feedback

Do you have any feedback about this page? We'd love to hear it!

The jOOQ Logo