From 89b6262fa4adb6c52719d53cabc632304cbd4f67 Mon Sep 17 00:00:00 2001 From: Matej Ferencevic Date: Thu, 3 Sep 2020 10:17:13 +0200 Subject: [PATCH] Fix multiline query concatenation character Reviewers: buda Reviewed By: buda Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D2814 --- tools/src/mg_client/main.cpp | 4 +-- .../input/multiline_query_with_comments.txt | 18 +++++++++++ .../client/output_csv/multiline_query.txt | 4 +-- .../multiline_query_with_comments.txt | 12 ++++++++ .../client/output_tabular/multiline_query.txt | 20 ++++++------- .../multiline_query_with_comments.txt | 30 +++++++++++++++++++ 6 files changed, 74 insertions(+), 14 deletions(-) create mode 100644 tools/tests/client/input/multiline_query_with_comments.txt create mode 100644 tools/tests/client/output_csv/multiline_query_with_comments.txt create mode 100644 tools/tests/client/output_tabular/multiline_query_with_comments.txt diff --git a/tools/src/mg_client/main.cpp b/tools/src/mg_client/main.cpp index 52e66969d..f444ce4c7 100644 --- a/tools/src/mg_client/main.cpp +++ b/tools/src/mg_client/main.cpp @@ -359,8 +359,8 @@ static std::optional GetQuery() { is_done = true; char_count += 1; // ';' sign } else { - // Query is multiline so append whitespace. - query << " "; + // Query is multiline so append newline. + query << "\n"; } if (char_count < line->size()) { default_text = utils::Trim(line->substr(char_count)); diff --git a/tools/tests/client/input/multiline_query_with_comments.txt b/tools/tests/client/input/multiline_query_with_comments.txt new file mode 100644 index 000000000..50474bc59 --- /dev/null +++ b/tools/tests/client/input/multiline_query_with_comments.txt @@ -0,0 +1,18 @@ +CREATE (n:Constantine{quote:"In hoc signo vinces"}) +RETURN n; +MATCH +(n) +// comment +RETURN +n; +CREATE (n:Erdody{quote: +"Regnum regno non praescribit leges"}) +RETURN +n; +// comment +MATCH (n:Erdody) RETURN +n; +CREATE (n:Caesar{quote:"Alea iacta est"}) +RETURN n; +MATCH (n:Caesar) +RETURN n; diff --git a/tools/tests/client/output_csv/multiline_query.txt b/tools/tests/client/output_csv/multiline_query.txt index 400253b9a..752dc2476 100644 --- a/tools/tests/client/output_csv/multiline_query.txt +++ b/tools/tests/client/output_csv/multiline_query.txt @@ -7,6 +7,6 @@ "n" "(:Erdody {quote: ""Regnum regno non praescribit leges""})" "n" -"(:Caesar {quote: ""Alea iacta est""})" +"(:Caesar {quote: ""Alea iacta\nest""})" "n" -"(:Caesar {quote: ""Alea iacta est""})" +"(:Caesar {quote: ""Alea iacta\nest""})" diff --git a/tools/tests/client/output_csv/multiline_query_with_comments.txt b/tools/tests/client/output_csv/multiline_query_with_comments.txt new file mode 100644 index 000000000..400253b9a --- /dev/null +++ b/tools/tests/client/output_csv/multiline_query_with_comments.txt @@ -0,0 +1,12 @@ +"n" +"(:Constantine {quote: ""In hoc signo vinces""})" +"n" +"(:Constantine {quote: ""In hoc signo vinces""})" +"n" +"(:Erdody {quote: ""Regnum regno non praescribit leges""})" +"n" +"(:Erdody {quote: ""Regnum regno non praescribit leges""})" +"n" +"(:Caesar {quote: ""Alea iacta est""})" +"n" +"(:Caesar {quote: ""Alea iacta est""})" diff --git a/tools/tests/client/output_tabular/multiline_query.txt b/tools/tests/client/output_tabular/multiline_query.txt index 74caf466c..50beb3613 100644 --- a/tools/tests/client/output_tabular/multiline_query.txt +++ b/tools/tests/client/output_tabular/multiline_query.txt @@ -18,13 +18,13 @@ +---------------------------------------------------------+ | (:Erdody {quote: "Regnum regno non praescribit leges"}) | +---------------------------------------------------------+ -+-------------------------------------+ -| n | -+-------------------------------------+ -| (:Caesar {quote: "Alea iacta est"}) | -+-------------------------------------+ -+-------------------------------------+ -| n | -+-------------------------------------+ -| (:Caesar {quote: "Alea iacta est"}) | -+-------------------------------------+ ++--------------------------------------+ +| n | ++--------------------------------------+ +| (:Caesar {quote: "Alea iacta\nest"}) | ++--------------------------------------+ ++--------------------------------------+ +| n | ++--------------------------------------+ +| (:Caesar {quote: "Alea iacta\nest"}) | ++--------------------------------------+ diff --git a/tools/tests/client/output_tabular/multiline_query_with_comments.txt b/tools/tests/client/output_tabular/multiline_query_with_comments.txt new file mode 100644 index 000000000..74caf466c --- /dev/null +++ b/tools/tests/client/output_tabular/multiline_query_with_comments.txt @@ -0,0 +1,30 @@ ++-----------------------------------------------+ +| n | ++-----------------------------------------------+ +| (:Constantine {quote: "In hoc signo vinces"}) | ++-----------------------------------------------+ ++-----------------------------------------------+ +| n | ++-----------------------------------------------+ +| (:Constantine {quote: "In hoc signo vinces"}) | ++-----------------------------------------------+ ++---------------------------------------------------------+ +| n | ++---------------------------------------------------------+ +| (:Erdody {quote: "Regnum regno non praescribit leges"}) | ++---------------------------------------------------------+ ++---------------------------------------------------------+ +| n | ++---------------------------------------------------------+ +| (:Erdody {quote: "Regnum regno non praescribit leges"}) | ++---------------------------------------------------------+ ++-------------------------------------+ +| n | ++-------------------------------------+ +| (:Caesar {quote: "Alea iacta est"}) | ++-------------------------------------+ ++-------------------------------------+ +| n | ++-------------------------------------+ +| (:Caesar {quote: "Alea iacta est"}) | ++-------------------------------------+