Fix escaper

This commit is contained in:
Meatballs 2013-06-24 23:50:33 +01:00
parent 4595b2c287
commit eb2012c599

View File

@ -16,6 +16,11 @@ class Syntax(GenericSyntax):
@staticmethod @staticmethod
def escape(expression, quote=True): def escape(expression, quote=True):
"""
>>> Syntax.escape("SELECT 'abcdefgh' FROM foobar")
'SELECT CHAR(97)||CHAR(98)||CHAR(99)||CHAR(100)||CHAR(101)||CHAR(102)||CHAR(103)||CHAR(104) FROM foobar'
"""
def escaper(value): def escaper(value):
retVal = "||".join("CHAR(%d)" % ord(value[i]) for i in xrange(len(value))) return "||".join("CHAR(%d)" % ord(value[i]) for i in xrange(len(value)))
return retVal
return Syntax._escape(expression, quote, escaper)