From 5bc1f17cb53248e7cea609693a3b2a9bb702545b Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Fri, 2 Jan 2009 21:24:17 +0000 Subject: - mysql, postgres: "%" signs in text() constructs are automatically escaped to "%%". Because of the backwards incompatible nature of this change, a warning is emitted if '%%' is detected in the string. [ticket:1267] --- lib/sqlalchemy/databases/postgres.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/sqlalchemy/databases/postgres.py') diff --git a/lib/sqlalchemy/databases/postgres.py b/lib/sqlalchemy/databases/postgres.py index 273f5859e..6fd0662de 100644 --- a/lib/sqlalchemy/databases/postgres.py +++ b/lib/sqlalchemy/databases/postgres.py @@ -719,6 +719,11 @@ class PGCompiler(compiler.DefaultCompiler): else: return "nextval('%s')" % self.preparer.format_sequence(seq) + def post_process_text(self, text): + if '%%' in text: + util.warn("The SQLAlchemy psycopg2 dialect now automatically escapes '%' in text() expressions to '%%'.") + return text.replace('%', '%%') + def limit_clause(self, select): text = "" if select._limit is not None: -- cgit v1.2.1