Skip to content

Preserve null and empty property names in JSON paths - #4172

Open
gabisonia wants to merge 1 commit into
npgsql:mainfrom
gabisonia:fix/4169-json-path-null
Open

gabisonia wants to merge 1 commit into
npgsql:mainfrom
gabisonia:fix/4169-json-path-null

Conversation

@gabisonia

Copy link
Copy Markdown

PostgreSQL reads an unquoted null in an array literal as a SQL NULL element, regardless of case. A predicate on a nested JSON property with that name can silently miss matching rows, and a unique expression index on the same path can accept duplicates.

Use the existing ARRAY[...]::text[] syntax when a path contains a case variant of null or an empty property name. For example, the mapped path Nested.null now produces ARRAY['Nested','null']::text[]. Existing affected indexes need to be recreated to pick up the corrected expression.

The regression tests exercise JSON DOM access through an array element, a mapped complex property, and duplicate rejection by a PostgreSQL unique index. All five cases failed with the original generator. The affected Release suites passed with 752 tests passing and 8 skipped.

Fixes #4169.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A JSON property named null is written into an unquoted path literal, which PostgreSQL reads as a NULL element: the query matches no rows

1 participant