Fix graph creation in tck
Summary: Parsing query with string values wasn't correct. It didn't matter with which type of quote mark string value started. It simply took any possible quote mark which wasn't escaped as possible beginning or end for string value. Following example didn't work: {name: "Chris Anderson: Technology's long tail"} Detected string value was "Chris Anderson: Technology' and because of that query broke. Now, string is detected by memorizing which quote mark was used to start parsing string value and is required to end string value with that quote mark. Reviewers: teon.banek, msantl Reviewed By: teon.banek Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D1029
This commit is contained in:
parent
73c01cfb73
commit
be9fe9fe75
@ -41,26 +41,26 @@ def create_graph(name, context):
|
||||
|
||||
with open(path, 'r') as f:
|
||||
content = f.read().replace('\n', ' ')
|
||||
q = ''
|
||||
in_string = False
|
||||
single_query = ''
|
||||
quote = None
|
||||
i = 0
|
||||
while i < len(content):
|
||||
ch = content[i]
|
||||
if ch == '\\' and i != len(content) - 1 and content[i + 1] in q_marks:
|
||||
q += ch + content[i + 1]
|
||||
single_query += ch + content[i + 1]
|
||||
i += 2
|
||||
else:
|
||||
q += ch
|
||||
if in_string and ch in q_marks:
|
||||
in_string = False
|
||||
elif ch in q_marks:
|
||||
in_string = True
|
||||
if ch == ';' and not in_string:
|
||||
database.query(q, context)
|
||||
q = ''
|
||||
single_query += ch
|
||||
if quote == ch:
|
||||
quote = None
|
||||
elif ch in q_marks and quote is None:
|
||||
quote = ch
|
||||
if ch == ';' and quote is None:
|
||||
database.query(single_query, context)
|
||||
single_query = ''
|
||||
i += 1
|
||||
if q.strip() != '':
|
||||
database.query(q, context)
|
||||
if single_query.strip() != '':
|
||||
database.query(single_query, context)
|
||||
context.graph_properties.set_beginning_parameters()
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user