Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5b6c01d

Browse files
committed
Escaper
1 parent 604694c commit 5b6c01d

1 file changed

Lines changed: 1 addition & 13 deletions

File tree

plugins/dbms/hsql/syntax.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,6 @@ def __init__(self):
1616

1717
@staticmethod
1818
def escape(expression, quote=True):
19-
"""
20-
TODO: Unsure of a method to escape. Perhaps RAWTOHEX/HEXTORAW functions?
21-
>>> Syntax.escape("SELECT 'abcdefgh' FROM foobar")
22-
'SELECT 'abcdefgh' FROM foobar'
23-
"""
24-
2519
def escaper(value):
26-
retVal = None
27-
try:
28-
retVal = "'%s'" % value
29-
except UnicodeEncodeError:
30-
retVal = "CONVERT(0x%s USING utf8)" % "".join("%.2x" % ord(_) for _ in utf8encode(value))
20+
retVal = "||".join("CHAR(%d)" % ord(value[i]) for i in xrange(len(value)))
3121
return retVal
32-
33-
return Syntax._escape(expression, quote, escaper)

0 commit comments

Comments
 (0)