Skip to content

Latest commit

 

History

History
27 lines (18 loc) · 1.09 KB

README.md

File metadata and controls

27 lines (18 loc) · 1.09 KB

Using CASE's is great however when there are too many conditions it can get uber complicated, this solves a very specific problem I've encountered.

Input

boolif(value: true, expected: true, output: 'It works!', fallback: '')

Variable Type Required Description
value boolean Yes Boolean value from the database.
expected boolean Yes The expected boolean value in order to return the output.
output varchar Yes Will be returned when value and expected are a match.
fallback varchar Optional Will return NULL unless set to a specific fallback when value and expected do not match.

Installation

By default it will be added to the public schema.

Usage

With default fallback:

  • SELECT boolif(true, true, 'It works!'); returns 'It works!'
  • SELECT boolif(false, true, 'It works!'); returns NULL

With custom fallback:

  • SELECT boolif(true, true, 'It works!', 'Oh yeah!'); returns 'It works!'
  • SELECT boolif(false, true, 'It works!', 'Oh yeah!'); returns 'Oh yeah!'