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

Duplicate results no filter #92

Open
gkorland opened this issue Mar 14, 2022 · 1 comment · May be fixed by #93
Open

Duplicate results no filter #92

gkorland opened this issue Mar 14, 2022 · 1 comment · May be fixed by #93

Comments

@gkorland
Copy link
Contributor

Filter might return duplicate results when the internal objects are similar.

e.g. input JSON both objects have name == {"first":"A","middle":"A"}

[{{"name":{"first":"A","middle":"A"},"rank":8},{"name":{"first":"A","middle":"A"},"rank":90}]

When running:

$[?($.name.first=="A")]

The following result is returned:

[{{"name":{"first":"A","middle":"A"},"rank":8},{"name":{"first":"A","middle":"A"},"rank":8},{{"name":{"first":"A","middle":"A"},"rank":90},{"name":{"first":"A","middle":"A"},"rank":90}]

It seems like the bug is in this code which compares all the candidates with all values and return each "parent" twice.

for result_value in &ret {

ref RedisJSON/RedisJSON#667

@cburgmer
Copy link

cburgmer commented Mar 9, 2023

Here's a working example (above syntax is broken):

[{"name":{"first":"A"},"rank":8},{"name":{"first":"A"},"rank":90}]

for selector

$[?(@.name.first=="A")]

Interestingly enough a simpler document works:

[{"name": "A","rank":8},{"name": "A","rank":90}]

$[?(@.name=="A")]

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 a pull request may close this issue.

2 participants