Skip to content

Instantly share code, notes, and snippets.

@dpirotte
Last active April 2, 2019 14:11
Show Gist options
  • Save dpirotte/e3958f2d0bde1fb4273c7e08c5673743 to your computer and use it in GitHub Desktop.
Save dpirotte/e3958f2d0bde1fb4273c7e08c5673743 to your computer and use it in GitHub Desktop.
null behavior for null people
lol=# select
null = true as null_eq_true,
null = false as null_eq_false,
null != true as null_neq_true,
null != false as null_neq_false,
null = null as null_eq_null,
null != null as null_neq_null,
null is true as null_is_true,
null is false as null_is_false,
null is null as null_is_null,
null is not true as null_is_not_true,
null is not false as null_is_not_false,
null is not null as null_is_not_null,
(null) is null as parenthetical_null_is_null,
(not null) is null as parenthetical_not_null_is_null,
null = ALL (ARRAY[]::int[]) as null_eq_all_empty_array,
null = ANY (ARRAY[]::int[]) as null_eq_any_empty_array,
null != ALL (ARRAY[]::int[]) as null_neq_all_empty_array,
null != ANY (ARRAY[]::int[]) as null_neq_any_empty_array
;
-[ RECORD 1 ]------------------+--
null_eq_true |
null_eq_false |
null_neq_true |
null_neq_false |
null_eq_null |
null_neq_null |
null_is_true | f
null_is_false | f
null_is_null | t
null_is_not_true | t
null_is_not_false | t
null_is_not_null | f
parenthetical_null_is_null | t
parenthetical_not_null_is_null | t
null_eq_all_empty_array | t
null_eq_any_empty_array | f
null_neq_all_empty_array | t
null_neq_any_empty_array | f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment