From be9fe9fe75c75831f1e77f7c42fb1c2a8cedb433 Mon Sep 17 00:00:00 2001 From: Marko Culinovic Date: Tue, 5 Dec 2017 16:23:12 +0100 Subject: [PATCH] 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 --- tests/qa/tck_engine/steps/graph.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/qa/tck_engine/steps/graph.py b/tests/qa/tck_engine/steps/graph.py index 5521892d2..924d4188f 100644 --- a/tests/qa/tck_engine/steps/graph.py +++ b/tests/qa/tck_engine/steps/graph.py @@ -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()