Created
May 15, 2024 19:16
-
-
Save igstan/6694deecaddf88b557e1b3037f066446 to your computer and use it in GitHub Desktop.
SQL NULL & JSON NULL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
jsonb_set( | |
'{"deeply": {"nested": {"field": 1}}}'::jsonb, | |
'{deeply,nested,field}', | |
to_jsonb(NULL::int) | |
) AS with_null_arg, | |
jsonb_set( | |
'{"deeply": {"nested": {"field": 1}}}'::jsonb, | |
'{deeply,nested,field}', | |
to_jsonb(1234::int) | |
) AS sans_null_arg; | |
-- ┌───────────────┬─────────────────────────────────────────┐ | |
-- │ with_null_arg │ sans_null_arg │ | |
-- ├───────────────┼─────────────────────────────────────────┤ | |
-- │ 𝗡𝗨𝗟𝗟 │ {"deeply": {"nested": {"field": 1234}}} │ | |
-- └───────────────┴─────────────────────────────────────────┘ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment