summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/databases/mysql.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2009-01-02 21:24:17 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2009-01-02 21:24:17 +0000
commit5bc1f17cb53248e7cea609693a3b2a9bb702545b (patch)
treee31a0341ecacd3115612fcebfc904f1549535465 /lib/sqlalchemy/databases/mysql.py
parent2f2d84fbb14f1282677de8fc1186da8f41081214 (diff)
downloadsqlalchemy-5bc1f17cb53248e7cea609693a3b2a9bb702545b.tar.gz
- 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]
Diffstat (limited to 'lib/sqlalchemy/databases/mysql.py')
-rw-r--r--lib/sqlalchemy/databases/mysql.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/sqlalchemy/databases/mysql.py b/lib/sqlalchemy/databases/mysql.py
index 86fb7b247..1b977dce9 100644
--- a/lib/sqlalchemy/databases/mysql.py
+++ b/lib/sqlalchemy/databases/mysql.py
@@ -1952,6 +1952,11 @@ class MySQLCompiler(compiler.DefaultCompiler):
return 'CAST(%s AS %s)' % (self.process(cast.clause), type_)
+ def post_process_text(self, text):
+ if '%%' in text:
+ util.warn("The SQLAlchemy MySQLDB dialect now automatically escapes '%' in text() expressions to '%%'.")
+ return text.replace('%', '%%')
+
def get_select_precolumns(self, select):
if isinstance(select._distinct, basestring):
return select._distinct.upper() + " "