Skip to content

Commit

Permalink
feat: add id null json values til
Browse files Browse the repository at this point in the history
  • Loading branch information
jthodge committed Aug 28, 2024
1 parent 54db850 commit dd70425
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions postgres/identify-null-json-values.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Idenfity `NULL` JSON Values

```sql
SELECT id, metadata FROM $TABLE_NAME
WHERE jsonb_typeof(metadata) != 'object'
OR jsonb_path_exists(metadata, '$.keyvalue() ? (@.value == null)')
```

Given a table, `$TABLE_NAME`, that possesses a JSONB column, `metadata`, the above query will return all rows in `$TABLE_NAME` where `metadata` is not `NULL`, but some value _within_ `metadata` is `NULL`.

0 comments on commit dd70425

Please sign in to comment.