diff --git a/redisgraph/graph.py b/redisgraph/graph.py index a12fe7f..cb6f4c3 100644 --- a/redisgraph/graph.py +++ b/redisgraph/graph.py @@ -157,7 +157,10 @@ def flush(self): self.edges = [] def _build_params_header(self, params): - if not isinstance(params, dict): + if isinstance(params, str): + #params is in header format use it as is + return params + elif not isinstance(params, dict): raise TypeError("'params' must be a dict") # Header starts with "CYPHER" params_header = "CYPHER " @@ -185,10 +188,6 @@ def query(self, q, params=None, timeout=None, read_only=False): # maintain original 'q' query = q - # handle query parameters - if params is not None: - query = self._build_params_header(params) + query - # construct query command # ask for compact result-set format # specify known graph version @@ -196,6 +195,10 @@ def query(self, q, params=None, timeout=None, read_only=False): # command = [cmd, self.name, query, "--compact", "version", self.version] command = [cmd, self.name, query, "--compact"] + # query params are specified + if params: + command += ["query_params", self._build_params_header(params)] + # include timeout is specified if timeout: if not isinstance(timeout, int): @@ -234,9 +237,9 @@ def execution_plan(self, query, params=None): params: query parameters """ if params is not None: - query = self._build_params_header(params) + query - - plan = self.redis_con.execute_command("GRAPH.EXPLAIN", self.name, query) + plan = self.redis_con.execute_command("GRAPH.EXPLAIN", self.name, query, "query_params", self._build_params_header(params)) + else: + plan = self.redis_con.execute_command("GRAPH.EXPLAIN", self.name, query) return self._execution_plan_to_string(plan) def delete(self):