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

JSON-Set : Not able to update fields with string values #2965

Open
Prophet0fRegret opened this issue Apr 8, 2024 · 0 comments
Open

JSON-Set : Not able to update fields with string values #2965

Prophet0fRegret opened this issue Apr 8, 2024 · 0 comments

Comments

@Prophet0fRegret
Copy link

Prophet0fRegret commented Apr 8, 2024

JSON-Set command is not able to update the specified field in the command with the supplied value if it is a STRING. It completes successfully if the value is something other, for example, an integer.

Expected Behavior

JSON-Set should be able to update JSON fields with string values.

Current Behavior

JSON-Set is not able to update JSON fields with string values. The command returns the following error : "expected value at line 1 column 1"

Possible Solution

Error is returned when entering the following command in CLI or from the lib :
JSON:SET <key> <path.subpath> <STRING value to be set>

But no errors are returned when the same operation is tried using the following command from the CLI :
JSON:SET <key> <path.subpath> '"<STRING value to be set>"'

The issue gets fixed if you enclose the string value with double-quotes (""), & then also enclose it within single-quotes('). Does not work if you try either of them, or none.

Steps to Reproduce

For the record, I believe I am on the latest version of the package, which is v9.5.1, at the time of reporting this bug.

  1. Try to set a new JSON object using a similar command : JSON.SET doc . '{"a":"2"}'
  2. Try to update the key, here, a, with a similar command : JSON.SET doc .a "7"
  3. Receive the above mentioned error

Context (Environment)

I am trying to update a field in an existing JSON document in REDIS. Using the go-redis package, I am able to set a new JSON object with the JsonSET() function. But when trying to utilise the same function to update a specific field with a string value, it gives the error.

I am not able to find any other alternative function which allows to update the fields. When faced with the same issue on the CLI, I tried different combinations and deduced that the string value that I am trying to update for the field needs to be enclosed in both th double-quotes and single-quotes for it to work.

Possible Implementation

I believe the change should be in the way the string is being parsed and sent to REDIS. I tried some stuff, like adding escape characters, but it still gives the same issue.

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

No branches or pull requests

1 participant