absurdfarce commented on code in PR #4653:
URL: https://github.com/apache/cassandra/pull/4653#discussion_r3066626244
##########
pylib/cqlshlib/cqlhandling.py:
##########
@@ -132,6 +132,43 @@ def cql_parse(self, text, startsymbol='Start'):
tokens = self.cql_massage_tokens(tokens)
return self.parse(startsymbol, tokens, init_bindings={'*SRC*': text})
+ @staticmethod
+ def dequote_value(cqlword):
+ cqlword = cqlword.strip()
+ if cqlword == '':
+ return cqlword
+ if cqlword[0] == "'" and cqlword[-1] == "'":
+ cqlword = cqlword[1:-1].replace("''", "'")
+ return cqlword
+
+ @staticmethod
+ def dequote_name(name):
+ name = name.strip()
+ if name == '':
+ return name
+ if name[0] == '"' and name[-1] == '"':
+ return name[1:-1].replace('""', '"')
+ else:
+ return name.lower()
+
+ @staticmethod
+ def escape_value(value):
+ if value is None:
+ return 'NULL' # this totally won't work
+ if isinstance(value, bool):
+ value = str(value).lower()
+ elif isinstance(value, float):
+ return '%f' % value
+ elif isinstance(value, int):
+ return str(value)
Review Comment:
The point isn't wrong, and if we were talking about a general-purpose
library I guess I'd be more worried about this kind of thing. But the current
usages pretty clearly cover dealing with strings, specifically standardized
strings representing the various options.
I'll also point out the impl here is identical to the original impl... and
this hasn't been a concern reported for cqlsh as it stands now.
I'm inclined not to worry about this. If we were making use of type
annotations I'd argue for something like that to make this clearer... but I
don't think we need to address it here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]