Add comments to more explicitly state the process in cql_quote

This commit is contained in:
Tim Savage
2014-03-22 11:19:56 +11:00
parent 36bdd89675
commit b56ad8587d

View File

@@ -13,8 +13,14 @@ if six.PY3:
def cql_quote(term):
# The ordering of this method is important for the result of this method to
# be a native str type (for both Python 2 and 3)
# Handle quoting of native str and bool types
if isinstance(term, (str, bool)):
return "'%s'" % str(term).replace("'", "''")
# This branch of the if statement will only be used by Python 2 to catch
# unicode strings, text_type is used to prevent type errors with Python 3.
elif isinstance(term, six.text_type):
return "'%s'" % term.encode('utf8').replace("'", "''")
else: