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

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.

Trivial predicates

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

predicates can be trivial, in case of which the expression can be removed and replaced by a TRUE or FALSE condition.

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

-- With Settings.transformPatternsTrivialPredicates active, this:
SELECT
  a IS NOT DISTINCT FROM a,
  a IS DISTINCT FROM a,
  a >= a,
  a <= a,
  a > a,
  a < a,
  const IS NOT NULL,
  const IS NULL,
  TRUE AND FALSE,
  TRUE OR FALSE,
  NOT TRUE,
  NOT FALSE,
  p = TRUE,
  p <> TRUE,
  p = FALSE,
  p <> FALSE,
  p AND (q OR p),
  p OR (q AND p)
  -- and many more
FROM tab;

-- ... is transformed into the equivalent expression:
SELECT
  TRUE,    -- a IS NOT DISTINCT FROM a
  FALSE,   -- a IS DISTINCT FROM a
  a = a,   -- a >= a
  a = a,   -- a <= a
  a != a,  -- a > a
  a != a,  -- a < a
  TRUE,    -- const IS NOT NULL
  FALSE,   -- const IS NULL
  FALSE,   -- TRUE AND FALSE
  TRUE,    -- TRUE OR FALSE
  FALSE,   -- NOT TRUE
  TRUE,    -- NOT FALSE
  p,       -- p = TRUE
  NOT (p), -- p <> TRUE
  NOT (p), -- p = FALSE
  p,       -- p <> FALSE,
  p,       -- p AND (q OR p)
  p        -- p OR (q AND p)
  -- and many more
FROM tab;

Feedback

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

The jOOQ Logo