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
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):
retVal = "||".join("CHAR(%d)" % ord(value[i]) for i in xrange(len(value)))
return retVal
return "||".join("CHAR(%d)" % ord(value[i]) for i in xrange(len(value)))
return Syntax._escape(expression, quote, escaper)