diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2009-01-14 19:55:20 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2009-01-14 19:55:20 +0000 |
commit | 76a7818013b1803876da7f51ec1601a25cb1e78b (patch) | |
tree | efe808502f9e9c9a4d5a35fe92c6df6bf5609ab3 /lib/sqlalchemy/sql/compiler.py | |
parent | 4fad095858e218c1c53de3c1ce64fc438688f826 (diff) | |
download | sqlalchemy-76a7818013b1803876da7f51ec1601a25cb1e78b.tar.gz |
- Improved the methodology to handling percent signs in column
names from [ticket:1256]. Added more tests. MySQL and
Postgres dialects still do not issue correct CREATE TABLE
statements for identifiers with percent signs in them.
Diffstat (limited to 'lib/sqlalchemy/sql/compiler.py')
-rw-r--r-- | lib/sqlalchemy/sql/compiler.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index d5c85d71d..8622aeea4 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -277,7 +277,10 @@ class DefaultCompiler(engine.Compiled): schema_prefix = self.preparer.quote(column.table.schema, column.table.quote_schema) + '.' else: schema_prefix = '' - return schema_prefix + self.preparer.quote(column.table.name % self.anon_map, column.table.quote) + "." + name + tablename = column.table.name + if isinstance(tablename, sql._generated_label): + tablename = tablename % self.anon_map + return schema_prefix + self.preparer.quote(tablename, column.table.quote) + "." + name def escape_literal_column(self, text): """provide escaping for the literal_column() construct.""" @@ -410,12 +413,11 @@ class DefaultCompiler(engine.Compiled): return bind_name - _trunc_re = re.compile(r'%\((-?\d+ \w+)\)s', re.U) def _truncated_identifier(self, ident_class, name): if (ident_class, name) in self.truncated_names: return self.truncated_names[(ident_class, name)] - anonname = self._trunc_re.sub(lambda m: self.anon_map[m.group(1)], name) + anonname = name % self.anon_map if len(anonname) > self.label_length: counter = self.truncated_names.get(ident_class, 1) @@ -427,7 +429,7 @@ class DefaultCompiler(engine.Compiled): return truncname def _anonymize(self, name): - return self._trunc_re.sub(lambda m: self.anon_map[m.group(1)], name) + return name % self.anon_map def _process_anon(self, key): (ident, derived) = key.split(' ') |