diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-06-24 12:19:15 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-06-24 12:19:15 -0400 |
commit | 87664ce88ab8931ccaacbac3357f484069efe6e9 (patch) | |
tree | 5635f38b27d3d6c489f9aeb41509a8dc890cb263 /lib/sqlalchemy/sql/compiler.py | |
parent | 0adf381d994b0f374d2b6394bff5f2c423942c78 (diff) | |
download | sqlalchemy-87664ce88ab8931ccaacbac3357f484069efe6e9.tar.gz |
- The argument to "ESCAPE" of a LIKE operator or similar
is passed through render_literal_value(), which may
implement escaping of backslashes. [ticket:1400]
- Postgresql render_literal_value() is overridden which escapes
backslashes, currently applies to the ESCAPE clause
of LIKE and similar expressions.
Ultimately this will have to detect the value of
"standard_conforming_strings" for full behavior.
[ticket:1400]
- MySQL render_literal_value() is overridden which escapes
backslashes, currently applies to the ESCAPE clause
of LIKE and similar expressions. This behavior
is derived from detecting the value of
NO_BACKSLASH_ESCAPES. [ticket:1400]
Diffstat (limited to 'lib/sqlalchemy/sql/compiler.py')
-rw-r--r-- | lib/sqlalchemy/sql/compiler.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index b4992eec3..c54931b87 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -494,28 +494,36 @@ class SQLCompiler(engine.Compiled): return '%s LIKE %s' % ( self.process(binary.left, **kw), self.process(binary.right, **kw)) \ - + (escape and ' ESCAPE \'%s\'' % escape or '') + + (escape and + (' ESCAPE ' + self.render_literal_value(escape, None)) + or '') def visit_notlike_op(self, binary, **kw): escape = binary.modifiers.get("escape", None) return '%s NOT LIKE %s' % ( self.process(binary.left, **kw), self.process(binary.right, **kw)) \ - + (escape and ' ESCAPE \'%s\'' % escape or '') + + (escape and + (' ESCAPE ' + self.render_literal_value(escape, None)) + or '') def visit_ilike_op(self, binary, **kw): escape = binary.modifiers.get("escape", None) return 'lower(%s) LIKE lower(%s)' % ( self.process(binary.left, **kw), self.process(binary.right, **kw)) \ - + (escape and ' ESCAPE \'%s\'' % escape or '') + + (escape and + (' ESCAPE ' + self.render_literal_value(escape, None)) + or '') def visit_notilike_op(self, binary, **kw): escape = binary.modifiers.get("escape", None) return 'lower(%s) NOT LIKE lower(%s)' % ( self.process(binary.left, **kw), self.process(binary.right, **kw)) \ - + (escape and ' ESCAPE \'%s\'' % escape or '') + + (escape and + (' ESCAPE ' + self.render_literal_value(escape, None)) + or '') def _operator_dispatch(self, operator, element, fn, **kw): if util.callable(operator): |