Skip to content

fix(jsonb): quote JSONPath names that would not read back - #11756

Merged
Xuanwo merged 2 commits into
lance-format:mainfrom
LuciferYang:fix/jsonb-path-display-quotes
Dec 2, 2026
Merged

Xuanwo merged 2 commits into
lance-format:mainfrom
LuciferYang:fix/jsonb-path-display-quotes

Conversation

@LuciferYang

Copy link
Copy Markdown
Contributor

Closes #11755.

Display for Path wrote DotField, ColonField and ObjectField names, and PathValue string literals, verbatim. A name containing a raw-name delimiter rendered as text that parses to a different path: $."a.b" printed as $.a.b, which is two fields; $."st\"ore" printed as $.st"ore, which does not parse. The golden file had the wrong output pinned.

A name is now written without quotes only when every character reads back unchanged. Names that contain a delimiter, whitespace, a backslash, or a control character are written as a double-quoted string with \"/\\/\uXXXX escaping. Object fields and string literals are always quoted. databendlabs/jsonb formats them the same way. No persisted bytes change.

How was this patch tested

test_json_path_display_round_trip re-parses the rendered text of four paths that contain delimiters and embedded quotes and asserts the round-trip produces the same parsed path. The json_path.txt golden line for $."st\"ore"."book💎" now renders with the first field quoted.

🤖 Generated with Claude Opus

Display for Path wrote DotField, ColonField and ObjectField names and PathValue string literals verbatim. A name containing a raw-name delimiter rendered as text that parses to a different path (`$."a.b"` printed as `$.a.b`) or does not parse at all, so a parsed path and its text were no longer the same path. The golden file pinned one such rendering.

Write a name unquoted only when it reads back unchanged, and always write object fields and string literals as escaped double-quoted strings. This is what databendlabs/jsonb does today. Display only; no persisted bytes change.

## How was this patch tested

`test_json_path_display_round_trip` re-parses the rendered text and compares it with the original path. The golden `json_path.txt` line for `$."st\"ore"."book…"` now renders quoted.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@github-actions github-actions Bot added the bug Something isn't working label Dec 2, 2026

@lance-gatekeeper lance-gatekeeper Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Gate recommendation: approve.

The fix addresses the formatting boundary directly and preserves the existing parser and stored JSONB contract.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Dec 2, 2026
@Xuanwo
Xuanwo merged commit 9477e62 into lance-format:main Dec 2, 2026
42 checks passed
@LuciferYang

Copy link
Copy Markdown
Contributor Author

Thanks @Xuanwo

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

Labels

bug Something isn't working K-approved Latest Gatekeeper recommendation permits acceptance.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: JsonPath to_string renders names that do not read back

2 participants