diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2008-03-30 21:48:19 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2008-03-30 21:48:19 +0000 |
commit | 7512b5e5482ea8a01095f98f82f1380f19a07110 (patch) | |
tree | c262ad7eae3bb2331a9bdd46fff79c2f3f46b9d7 /lib/sqlalchemy/sql | |
parent | c096aeefe04ff77dbbef084923c75bf928620a27 (diff) | |
download | sqlalchemy-7512b5e5482ea8a01095f98f82f1380f19a07110.tar.gz |
- schema-qualified tables now will place the schemaname
ahead of the tablename in all column expressions as well
as when generating column labels. This prevents cross-
schema name collisions in all cases [ticket:999]
- the "use_schema" argument to compiler.visit_column() is removed. It uses
schema in all cases now.
- added a new test to the PG dialect to test roundtrip insert/update/delete/select
statements with full schema qualification
Diffstat (limited to 'lib/sqlalchemy/sql')
-rw-r--r-- | lib/sqlalchemy/sql/compiler.py | 13 | ||||
-rw-r--r-- | lib/sqlalchemy/sql/expression.py | 5 |
2 files changed, 8 insertions, 10 deletions
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index ee3ecc1f1..76e2ca260 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -249,14 +249,9 @@ class DefaultCompiler(engine.Compiled): return " ".join([self.process(label.obj), self.operator_string(operators.as_), self.preparer.format_label(label, labelname)]) - def visit_column(self, column, result_map=None, use_schema=False, **kwargs): - # there is actually somewhat of a ruleset when you would *not* necessarily - # want to truncate a column identifier, if its mapped to the name of a - # physical column. but thats very hard to identify at this point, and - # the identifier length should be greater than the id lengths of any physical - # columns so should not matter. - - if use_schema and getattr(column, 'table', None) and getattr(column.table, 'schema', None): + def visit_column(self, column, result_map=None, **kwargs): + + if getattr(column, 'table', None) and getattr(column.table, 'schema', None): schema_prefix = self.preparer.quote(column.table, column.table.schema) + '.' else: schema_prefix = '' @@ -278,7 +273,7 @@ class DefaultCompiler(engine.Compiled): return schema_prefix + self.preparer.quote(column.table, ANONYMOUS_LABEL.sub(self._process_anon, column.table.name)) + "." + n elif len(column.table.primary_key) != 0: pk = list(column.table.primary_key)[0] - return self.visit_column(pk, result_map=result_map, use_schema=use_schema, **kwargs) + return self.visit_column(pk, result_map=result_map, **kwargs) else: return None elif column.table is None or not column.table.named_with_column: diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py index 3d95948cb..2cd10720a 100644 --- a/lib/sqlalchemy/sql/expression.py +++ b/lib/sqlalchemy/sql/expression.py @@ -2632,7 +2632,10 @@ class _ColumnClause(ColumnElement): return None if self.__label is None: if self.table is not None and self.table.named_with_column: - self.__label = self.table.name + "_" + self.name + if getattr(self.table, 'schema', None): + self.__label = "_".join([self.table.schema, self.table.name, self.name]) + else: + self.__label = "_".join([self.table.name, self.name]) counter = 1 while self.__label in self.table.c: self.__label = self.__label + "_%d" % counter |