You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by br...@apache.org on 2024/05/28 04:17:02 UTC
(cassandra) 02/03: added new unit test and removed strip comment
This is an automated email from the ASF dual-hosted git repository.
brads pushed a commit to branch cassandra-5.0
in repository https://gitbox.apache.org/repos/asf/cassandra.git
commit 6945deec68600c726a02c93a0084e37330587175
Author: vgali7 <vg...@gatech.edu>
AuthorDate: Tue Aug 8 15:41:15 2023 -0400
added new unit test and removed strip comment
---
pylib/cqlshlib/cqlshmain.py | 18 ------------------
pylib/cqlshlib/test/test_cql_parsing.py | 24 ++++++++++++++++++++++++
2 files changed, 24 insertions(+), 18 deletions(-)
diff --git a/pylib/cqlshlib/cqlshmain.py b/pylib/cqlshlib/cqlshmain.py
index 676dbf2e3d..e3a2c14ae4 100755
--- a/pylib/cqlshlib/cqlshmain.py
+++ b/pylib/cqlshlib/cqlshmain.py
@@ -433,7 +433,6 @@ class Shell(cmd.Cmd):
self.statement = StringIO()
self.lineno = 1
- self.in_comment = False
self.prompt = ''
if stdin is None:
@@ -816,23 +815,6 @@ class Shell(cmd.Cmd):
self.reset_statement()
print('')
- def strip_comment_blocks(self, statementtext):
- comment_block_in_literal_string = re.search('["].*[/][*].*[*][/].*["]', statementtext)
- if not comment_block_in_literal_string:
- result = re.sub('[/][*].*[*][/]', "", statementtext)
- if '*/' in result and '/*' not in result and not self.in_comment:
- raise SyntaxError("Encountered comment block terminator without being in comment block")
- if '/*' in result:
- result = re.sub('[/][*].*', "", result)
- self.in_comment = True
- if '*/' in result:
- result = re.sub('.*[*][/]', "", result)
- self.in_comment = False
- if self.in_comment and not re.findall('[/][*]|[*][/]', statementtext):
- result = ''
- return result
- return statementtext
-
def onecmd(self, statementtext):
"""
Returns true if the statement is complete and was handled (meaning it
diff --git a/pylib/cqlshlib/test/test_cql_parsing.py b/pylib/cqlshlib/test/test_cql_parsing.py
index b1f45f52fa..ba7cd6b5b1 100644
--- a/pylib/cqlshlib/test/test_cql_parsing.py
+++ b/pylib/cqlshlib/test/test_cql_parsing.py
@@ -771,6 +771,30 @@ class TestCqlParsing(TestCase):
('"/*MyTable*/"', 'quotedName'),
(';', 'endtoken')])
+ parsed = parse_cqlsh_statements('''
+ INSERT into a (key,c1,c2) VALUES ('aKey','v1','/v2/*/v3');
+ ''')
+ self.assertSequenceEqual(tokens_with_types(parsed),
+ [('INSERT','reserved_identifier'),
+ ('into','reserved_identifier'),
+ ('a','identifier'),
+ ('(','op'),
+ ('key','identifier'),
+ (',','op'),
+ ('c1','identifier'),
+ (',','op'),
+ ('c2','identifier'),
+ (')','op'),
+ ('VALUES','identifier'),
+ ('(','op'),
+ ("'aKey'",'quotedStringLiteral'),
+ (',','op'),
+ ("'v1'",'quotedStringLiteral'),
+ (',','op'),
+ ("'/v2/*/v3'",'quotedStringLiteral'),
+ (')','op'),
+ (';','endtoken')])
+
parse_cqlsh_statements('''
*/ SELECT FROM "MyTable";
''')
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org