diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2008-08-19 21:27:34 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2008-08-19 21:27:34 +0000 |
commit | 427ed1966f0f9ce13df49dcdbe43ce48333e94fa (patch) | |
tree | 20c34c3a838c37c73828473ea47e889c51f1fe8f /lib/sqlalchemy/sql/compiler.py | |
parent | 20c82967ca98ceead88401ca8f35f8cf0e758318 (diff) | |
download | sqlalchemy-427ed1966f0f9ce13df49dcdbe43ce48333e94fa.tar.gz |
- fixed a bug in declarative test which was looking for old version of history
- Added "sorted_tables" accessor to MetaData, which returns
Table objects sorted in order of dependency as a list.
This deprecates the MetaData.table_iterator() method.
The "reverse=False" keyword argument has also been
removed from util.sort_tables(); use the Python
'reversed' function to reverse the results.
[ticket:1033]
Diffstat (limited to 'lib/sqlalchemy/sql/compiler.py')
-rw-r--r-- | lib/sqlalchemy/sql/compiler.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index 4a47df941..eacbe59e1 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -20,7 +20,7 @@ is otherwise internal to SQLAlchemy. import string, re from sqlalchemy import schema, engine, util, exc -from sqlalchemy.sql import operators, functions +from sqlalchemy.sql import operators, functions, util as sql_util from sqlalchemy.sql import expression as sql RESERVED_WORDS = set([ @@ -787,7 +787,11 @@ class SchemaGenerator(DDLBase): return not self.checkfirst or not self.dialect.has_table(self.connection, table.name, schema=table.schema) def visit_metadata(self, metadata): - collection = [t for t in metadata.table_iterator(reverse=False, tables=self.tables) if self._can_create(t)] + if self.tables: + tables = self.tables + else: + tables = metadata.tables.values() + collection = [t for t in sql_util.sort_tables(tables) if self._can_create(t)] for table in collection: self.traverse_single(table) if self.dialect.supports_alter: @@ -950,7 +954,11 @@ class SchemaDropper(DDLBase): self.dialect = dialect def visit_metadata(self, metadata): - collection = [t for t in metadata.table_iterator(reverse=True, tables=self.tables) if self._can_drop(t)] + if self.tables: + tables = self.tables + else: + tables = metadata.tables.values() + collection = [t for t in reversed(sql_util.sort_tables(tables)) if self._can_drop(t)] if self.dialect.supports_alter: for alterable in self.find_alterables(collection): self.drop_foreignkey(alterable) |