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

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

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.

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;

Feedback

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

The jOOQ Logo