From b191254d8aceca10b40dd5957f3ddf9147a4c534 Mon Sep 17 00:00:00 2001 From: Ants Aasma Date: Tue, 26 Jun 2007 16:37:30 +0000 Subject: fix #624, modulo operator escaping on mysql and postgres someone should test this with oracle, firebird and sql server also --- lib/sqlalchemy/databases/mysql.py | 6 ++++++ lib/sqlalchemy/databases/postgres.py | 2 ++ 2 files changed, 8 insertions(+) (limited to 'lib/sqlalchemy/databases') diff --git a/lib/sqlalchemy/databases/mysql.py b/lib/sqlalchemy/databases/mysql.py index 91d59f1e2..6e4e0a660 100644 --- a/lib/sqlalchemy/databases/mysql.py +++ b/lib/sqlalchemy/databases/mysql.py @@ -1205,6 +1205,12 @@ class MySQLCompiler(ansisql.ANSICompiler): text += " \n LIMIT 18446744073709551615" text += " OFFSET " + str(select.offset) return text + + def binary_operator_string(self, binary): + if binary.operator == '%': + return '%%' + else: + return ansisql.ANSICompiler.binary_operator_string(self, binary) class MySQLSchemaGenerator(ansisql.ANSISchemaGenerator): def get_column_specification(self, column, override_pk=False, first_pk=False): diff --git a/lib/sqlalchemy/databases/postgres.py b/lib/sqlalchemy/databases/postgres.py index 0eca18be3..a514b9de0 100644 --- a/lib/sqlalchemy/databases/postgres.py +++ b/lib/sqlalchemy/databases/postgres.py @@ -532,6 +532,8 @@ class PGCompiler(ansisql.ANSICompiler): def binary_operator_string(self, binary): if isinstance(binary.type, sqltypes.String) and binary.operator == '+': return '||' + elif binary.operator == '%': + return '%%' else: return ansisql.ANSICompiler.binary_operator_string(self, binary) -- cgit v1.2.1