Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(json_family): Fix JSON.SET handling for nested fields #4710

Conversation

BagritsevichStepan
Copy link
Contributor

@BagritsevichStepan BagritsevichStepan commented Mar 5, 2025

fixes #4381

The main bug was in the ConvertExpressionToJsonPointer method. I don’t like the idea of parsing a JSON path directly. Instead, I decided to use our JSON path lexer to parse it first and then convert it into JsonPointer. For now, this approach should work fine.

I also spent a significant amount of time ensuring support for both our parsing method, json::ParsePath, and the jsoncons parsing method, depending on the jsonpathv2 flag. However, I found some bugs in the jsoncons parsing method, and it also needs modifications to allow us to extract path tokens and traverse them to convert them into a JsonPointer. And jsoncons does not provide any built-in methods to convert json_expression into json_pointer. So, I think this is the best solution for now.

Also, in this PR, I made some code cleanups.

@BagritsevichStepan BagritsevichStepan self-assigned this Mar 5, 2025
@BagritsevichStepan BagritsevichStepan force-pushed the json/fix-paths-in-brackets branch 2 times, most recently from ff8c972 to 685304e Compare March 5, 2025 20:56
@BagritsevichStepan BagritsevichStepan changed the title fix(json_family): Fix JSON.SET handling for nested fields in json_family fix(json_family): Fix JSON.SET handling for nested fields Mar 6, 2025

Verified

This commit was signed with the committer’s verified signature.
BagritsevichStepan Stepan Bagritsevich
fixes dragonflydb#4381

Signed-off-by: Stepan Bagritsevich <stefan@dragonflydb.io>
@BagritsevichStepan BagritsevichStepan force-pushed the json/fix-paths-in-brackets branch from 685304e to b89a9e4 Compare March 6, 2025 07:42
@adiholden adiholden requested a review from BorysTheDev March 6, 2025 08:07
@BagritsevichStepan BagritsevichStepan merged commit 5ffe939 into dragonflydb:main Mar 6, 2025
10 checks passed
@BagritsevichStepan BagritsevichStepan deleted the json/fix-paths-in-brackets branch March 6, 2025 08:53
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.

Wrong handling of JSON paths in brackets
2 participants