Minor fix for escaping unicode strings in SQLite escaper

This commit is contained in:
stamparm 2013-02-25 14:06:46 +01:00
parent e5e39bc682
commit 0d2138a4a0

View File

@ -8,6 +8,7 @@ See the file 'doc/COPYING' for copying permission
import binascii import binascii
from lib.core.common import isDBMSVersionAtLeast from lib.core.common import isDBMSVersionAtLeast
from lib.core.settings import UNICODE_ENCODING
from plugins.generic.syntax import Syntax as GenericSyntax from plugins.generic.syntax import Syntax as GenericSyntax
class Syntax(GenericSyntax): class Syntax(GenericSyntax):
@ -17,7 +18,7 @@ class Syntax(GenericSyntax):
@staticmethod @staticmethod
def escape(expression, quote=True): def escape(expression, quote=True):
def escaper(value): def escaper(value):
return "CAST(X'%s' AS TEXT)" % binascii.hexlify(value) return "CAST(X'%s' AS TEXT)" % binascii.hexlify(value.encode(UNICODE_ENCODING) if isinstance(value, unicode) else value)
retVal = expression retVal = expression