diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2009-08-09 22:11:40 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2009-08-09 22:11:40 +0000 |
| commit | f0d2e599b60317fc27f64f0abe7d2af65fba7e7b (patch) | |
| tree | b5133f1cffbbf90e299669c1e21544b90aacf674 /lib/sqlalchemy | |
| parent | 00d247edcc89ae7620d75112cd9183138db7ebe7 (diff) | |
| download | sqlalchemy-f0d2e599b60317fc27f64f0abe7d2af65fba7e7b.tar.gz | |
- PG: somewhat better support for % signs in table/column names;
psycopg2 can't handle a bind parameter name of
%(foobar)s however and SQLA doesn't want to add overhead
just to treat that one non-existent use case.
[ticket:1279]
- MySQL: somewhat better support for % signs in table/column names;
MySQLdb can't handle % signs in SQL when executemany() is used,
and SQLA doesn't want to add overhead just to treat that one
non-existent use case. [ticket:1279]
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/dialects/mysql/base.py | 7 | ||||
| -rw-r--r-- | lib/sqlalchemy/dialects/postgresql/base.py | 4 |
2 files changed, 10 insertions, 1 deletions
diff --git a/lib/sqlalchemy/dialects/mysql/base.py b/lib/sqlalchemy/dialects/mysql/base.py index 1c5c251e5..570d1a79b 100644 --- a/lib/sqlalchemy/dialects/mysql/base.py +++ b/lib/sqlalchemy/dialects/mysql/base.py @@ -2514,6 +2514,10 @@ class _MySQLIdentifierPreparer(compiler.IdentifierPreparer): return tuple([self.quote_identifier(i) for i in ids if i is not None]) + def _escape_identifier(self, value): + value = value.replace('"', '""') + return value.replace('%', '%%') + class MySQLIdentifierPreparer(_MySQLIdentifierPreparer): """Traditional MySQL-specific schema identifier configuration.""" @@ -2522,7 +2526,8 @@ class MySQLIdentifierPreparer(_MySQLIdentifierPreparer): super(MySQLIdentifierPreparer, self).__init__(dialect, initial_quote="`") def _escape_identifier(self, value): - return value.replace('`', '``') + value = value.replace('`', '``') + return value.replace('%', '%%') def _unescape_identifier(self, value): return value.replace('``', '`') diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py index fbba8221b..c89ae16bd 100644 --- a/lib/sqlalchemy/dialects/postgresql/base.py +++ b/lib/sqlalchemy/dialects/postgresql/base.py @@ -431,6 +431,10 @@ class PGIdentifierPreparer(compiler.IdentifierPreparer): value = value[1:-1].replace('""','"') return value + def _escape_identifier(self, value): + value = value.replace('"', '""') + return value.replace('%', '%%') + class PGInspector(reflection.Inspector): def __init__(self, conn): |
