-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Support for Gql variable in arrays #2981
Conversation
This change adds support for Gql variables in array arguments in inequality functions. Scalar arguments are still handled.
New tests TestParseGraphQLVarArray, TestParseGraphQLValueArray, and TestParseGraphQLMixedVarArray check usage of variable arrays in eq function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 3 files at r1.
Reviewable status: 2 of 3 files reviewed, 4 unresolved discussions (waiting on @srfrog)
gql/parser.go, line 1346 at r1 (raw file):
// parseIneqArgs will try to parse the arguments inside an array ([]). If the values // are prefixed with $ they are treated as Gql variables, otherwise used as scalar values.
otherwise they are used ...
gql/parser.go, line 1374 at r1 (raw file):
} g.Args = append(g.Args, Arg{Value: val}) break
It's unclear why we break here. Should this be continue?
If it's supposed to be a break statement, maybe add a short comment above explaining why.
gql/parser.go, line 1390 at r1 (raw file):
isDollar = false } return it.Errorf("Expecting ] to end list but none was found")
return it.Errorf("Expecting ] to end list but got %v instead", it.Item().Val)
types/geofilter.go, line 25 at r1 (raw file):
"github.com/golang/geo/s2" geom "github.com/twpayne/go-geom"
Package is already called geom so this is not doing anything.
https://github.com/twpayne/go-geom/blob/master/geom.go#L3
I doubt the package name will change on their end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 2 of 3 files reviewed, 4 unresolved discussions (waiting on @martinmr)
gql/parser.go, line 1346 at r1 (raw file):
Previously, martinmr (Martin Martinez Rivera) wrote…
otherwise they are used ...
Done.
gql/parser.go, line 1374 at r1 (raw file):
Previously, martinmr (Martin Martinez Rivera) wrote…
It's unclear why we break here. Should this be continue?
If it's supposed to be a break statement, maybe add a short comment above explaining why.
if we don't break we append the value twice.
gql/parser.go, line 1390 at r1 (raw file):
Previously, martinmr (Martin Martinez Rivera) wrote…
return it.Errorf("Expecting ] to end list but got %v instead", it.Item().Val)
Done.
types/geofilter.go, line 25 at r1 (raw file):
Previously, martinmr (Martin Martinez Rivera) wrote…
Package is already called geom so this is not doing anything.
https://github.com/twpayne/go-geom/blob/master/geom.go#L3
I doubt the package name will change on their end.
The import location has a non-standard name, this is added by the formatter. It's not based on the package name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 3 files at r1, 1 of 1 files at r2.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @martinmr)
…h-io/dgraph into srfrog/issue-2272_variable_arrays
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 3 of 4 files reviewed, all discussions resolved
Will this work in the case where we want to pass the array in as a variable?
I have a lot of queries that look like this, and having to dynamically generate the place holders: |
This won't work @F21 . And in the last version also don't work as far I can tell.
After |
@MichelDiz Should #2272 or #2726 be reopened? Those issues include support for passing a list as a variable to a query. |
Is this supported on
|
I guess this is only in master. I couldn't find any RC with this commit. So it will be in 1.1. |
* gql/parser.go: add support for gql variable arrays This change adds support for Gql variables in array arguments in inequality functions. Scalar arguments are still handled. * added comments, removed debug log statements, fixed typos * gql/parser_test.go: added tests for ineq var arrays New tests TestParseGraphQLVarArray, TestParseGraphQLValueArray, and TestParseGraphQLMixedVarArray check usage of variable arrays in eq function. * added and fixed comments, and other formatting changes * wiki/content/query-language/index.md: eq syntax with vars in array
Hey, any updates on the above ? I am using Dgraph 1.1, the python version and I still can't seem to pass in a str joined list of uids in the variable section against the uid lookup:
error:
|
@hamada969 this feels like a bug but you can do like:
In our public dataset should return:
|
This change adds support for Gql variables in array arguments of inequality functions.
Argument values are still handled.
Example with variables:
Mixed use:
Typical use without variables, should yield same result:
Closes #2272
This change is