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

$ as value is considered variable, despite quotes #4695

Closed
insanitybit opened this issue Jan 29, 2020 · 4 comments · Fixed by #4702
Closed

$ as value is considered variable, despite quotes #4695

insanitybit opened this issue Jan 29, 2020 · 4 comments · Fixed by #4702
Assignees
Labels
area/querylang/vars Issues related to queries with GraphQL variables area/querylang Issues related to the query language specification and implementation. investigate Requires further investigation kind/bug Something is broken. status/accepted We accept to investigate/work on it.

Comments

@insanitybit
Copy link

insanitybit commented Jan 29, 2020

What version of Dgraph are you using?

Dgraph version : v1.1.0
Dgraph SHA-256 : 7d4294a80f74692695467e2cf17f74648c18087ed7057d798f40e1d3a31d2095
Commit SHA-1 : ef7cdb2
Commit timestamp : 2019-09-04 00:12:51 -0700
Branch : HEAD
Go version : go1.12.7

Name: pydgraph
Version: 2.0.2
Summary: Official Dgraph client implementation for Python
Home-page: https://github.com/dgraph-io/pydgraph
Author: Dgraph Labs
Author-email: [email protected]
License: Apache License, Version 2.0
Requires: grpcio, protobuf
Required-by:

Have you tried reproducing the issue with the latest release?

This is the latest 'standalone' release.

What is the hardware spec (RAM, OS)?

16GB RAM, 8 core intel.

Ubuntu 18.04.

Steps to reproduce the issue (command/config used to run Dgraph).

docker run --rm -it -p 8000:8000 -p 8080:8080 -p 9080:9080 dgraph/standalone:latest

Create a node with a predicate 'foo' and a value '$' .

Attempt to filter by $.

Here is an example query I have:


node_key = "test_process_query_view_parity_eqe3e70682-c209-4cac-629f-6fbed82c07cd"

query = f"""
    {{
        q0(func: eq(node_key, "{node_key}"))
        @filter(eq(process_name, "$"))
        {{
                uid,
                process_name
        }}
    }}

    """

json.loads(local_client.txn(read_only=True).query(query).json)

Or
@filter(eq(process_name, "\x24"))
@filter(eq(process_name, "\$))
@filter(eq(process_name, "\\$"))
etc

Expected behaviour and actual result.

I expect to see the predicate returned,The $ is quoted, so I don't expect it to do any kind of string interpolation (otherwise I'd just do the interpolation outside of the query and pass that in as a var).

I also do not see any documentation for escaping this parameter.

debug_error_string = "{"created":"@1580339274.335410834","description":"Error received from peer ipv6:[::1]:9080","file":"src/core/lib/surface/call.cc","file_line":1055,"grpc_message":"Variable not defined $","grpc_status":2}"
@insanitybit
Copy link
Author

The recommendation seems to be to serialize $ as //$, and then deserialize //$ as $.
This seems to work, but it isn't documented anywhere and it seems like something that clients or the database should be handling.

I still think it's unexpected behavior for variables to work in quotes.

@MichelDiz MichelDiz added area/querylang Issues related to the query language specification and implementation. area/querylang/vars Issues related to queries with GraphQL variables investigate Requires further investigation kind/bug Something is broken. labels Jan 30, 2020
@poonai
Copy link
Contributor

poonai commented Jan 31, 2020

Hello @insanitybit ,

Thanks for reporting. We are working on a fix now.

I'll notify you, once the PR merges :)

@insanitybit
Copy link
Author

Thank you @balajijinnah

@sleto-it sleto-it added the status/accepted We accept to investigate/work on it. label Jan 31, 2020
@poonai
Copy link
Contributor

poonai commented Feb 20, 2020

@insanitybit PR merged 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/querylang/vars Issues related to queries with GraphQL variables area/querylang Issues related to the query language specification and implementation. investigate Requires further investigation kind/bug Something is broken. status/accepted We accept to investigate/work on it.
Development

Successfully merging a pull request may close this issue.

4 participants