forked from DiceDB/dice
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DiceDB#603: BugFix : Handle root path '.' correctly in JSON.OBJLEN co…
…mmand (DiceDB#976)
- Loading branch information
Showing
6 changed files
with
193 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package utils | ||
|
||
// This method returns the path, and a boolean value telling if the path provided follows Legacy Path Syntax or JSONPath syntax. | ||
// JSON knows which syntax to use depending on the first character of the path query. | ||
// If the query starts with the character $, it uses JSONPath syntax. Otherwise, it defaults to the legacy path syntax. | ||
// A JSONPath query can resolve to several locations in a JSON document. | ||
// In this case, the JSON commands apply the operation to every possible location. This is a major improvement over legacy path queries, which only operate on the first path. | ||
func ParseInputJSONPath(path string) (string, bool) { | ||
isLegacyPath := path[0] != '$' | ||
|
||
// Handle . path error | ||
if len(path) ==1 && path[0] == '.' { | ||
path = "$" | ||
} | ||
return path, isLegacyPath | ||
} |