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(query): fix has function in filter #9043

Merged
merged 1 commit into from
Mar 13, 2024
Merged

fix(query): fix has function in filter #9043

merged 1 commit into from
Mar 13, 2024

Conversation

mangalaman93
Copy link
Contributor

Currently when we have a language tagged predicate (example: name). Querying name should return only untagged values. name@. should return any language.

Consider dataset
<1> "first user" .
<2> name@en "second user" .

query (func: uid(1,2)) { uid name} would return "{uid: 1, name: first user}".
query (func: uid(1,2)) { uid name@.} would return "{{uid: 1, name@.: "first user"}, {uid: 2, name@.: "second user"}}".

However due to a bug, we are not enforcing this in @filter(has(name)). So this results in

query (func: has(dgraph.type)) @filter(has(name)) { uid name} results in
"{{uid: 1, name: "first user'}, {uid: 2}}"

Fix: We update @filter(has(name)) to filter on basis of language.

Currently when we have a language tagged predicate (example: name).
Querying name should return only untagged values. name@. should return
any language.

Consider dataset
<1> <name> "first user" .
<2> <name@en> "second user" .

query (func: uid(1,2)) { uid name} would return "{uid: 1, name: first
user}".
query (func: uid(1,2)) { uid name@.} would return "{{uid: 1, name@.:
"first user"}, {uid: 2, name@.: "second user"}}".

However due to a bug, we are not enforcing this in @filter(has(name)).
So this results in

query (func: has(dgraph.type)) @filter(has(name)) { uid name} results in
"{{uid: 1, name: "first user'}, {uid: 2}}"

Fix: We update @filter(has(name)) to filter on basis of language.

Fixes:
https://linear.app/hypermode/issue/HYP-311/inconsistent-counts-using-has-at-root

---------

Co-authored-by: Harshil Goel <harshil@dgraph.io>
@mangalaman93 mangalaman93 requested a review from a team as a code owner March 1, 2024 06:56
@dgraph-bot dgraph-bot added area/testing Testing related issues area/core internal mechanisms go Pull requests that update Go code labels Mar 1, 2024
@mangalaman93 mangalaman93 changed the title fix(query): fix has function in filter (#87) fix(query): fix has function in filter Mar 1, 2024
@mangalaman93 mangalaman93 merged commit a18d3ae into main Mar 13, 2024
11 checks passed
@mangalaman93 mangalaman93 deleted the aman/4f9f3d507 branch March 13, 2024 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/core internal mechanisms area/testing Testing related issues go Pull requests that update Go code
Development

Successfully merging this pull request may close these issues.

3 participants