Skip to content

support dict as a parameter value on _build_params_header #141

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions redisgraph/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,25 @@ def _build_params_header(self, params):
# Header starts with "CYPHER"
params_header = "CYPHER "
for key, value in params.items():
# If value is string add quotation marks.
if isinstance(value, str):
value = quote_string(value)
# Value is None, replace with "null" string.
elif value is None:
value = "null"
params_header += str(key) + "=" + str(value) + " "
params_header += str(key) + "=" + str(self._parse_value(value)) + " "
return params_header

def _parse_value(self, value):
# If value is string add quotation marks.
if isinstance(value, str):
value = quote_string(value)
# If value is dictionary, need to remove quotation mark
elif isinstance(value, dict):
temp_value = "{"
for key, val in value.items():
temp_value += str(key) + ":" + str(val) + ","
value = temp_value[:-1] + "}"
# Value is None, replace with "null" string.
elif value is None:
value = "null"

return value

def query(self, q, params=None, timeout=None, read_only=False):
"""
Executes a query against the graph.
Expand Down