diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-10-01 01:59:59 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-10-01 01:59:59 -0400 |
commit | 0bb5a9eab829f9a4cfda3c37cdf2202d84e55f3f (patch) | |
tree | 2e7847e098ac547b5907c6650e219e9b0a65236e /lib/sqlalchemy/schema.py | |
parent | eaa15b3c70020b96aebd2e05651eb18226ff4ee3 (diff) | |
download | sqlalchemy-0bb5a9eab829f9a4cfda3c37cdf2202d84e55f3f.tar.gz |
- fix the fixture here that wasn't creating consistently
- rewrite --dropfirst to be more industrial strength, includes views
- fix order_by="foreign_key" to maintain the same ordering as
metadata.sorted_tables. Not ideal that this was the other way throughout
0.7 but this is still a little-used method, in contrast to metadata.sorted_tables.
Diffstat (limited to 'lib/sqlalchemy/schema.py')
-rw-r--r-- | lib/sqlalchemy/schema.py | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/lib/sqlalchemy/schema.py b/lib/sqlalchemy/schema.py index d7720a867..859ccd99b 100644 --- a/lib/sqlalchemy/schema.py +++ b/lib/sqlalchemy/schema.py @@ -2536,8 +2536,18 @@ class MetaData(SchemaItem): @property def sorted_tables(self): - """Returns a list of ``Table`` objects sorted in order of - dependency. + """Returns a list of :class:`.Table` objects sorted in order of + foreign key dependency. + + The sorting will place :class:`.Table` objects that have dependencies + first, before the dependencies themselves, representing the + order in which they can be created. To get the order in which + the tables would be dropped, use the ``reversed()`` Python built-in. + + .. seealso:: + + :meth:`.Inspector.sorted_tables` + """ return sqlutil.sort_tables(self.tables.itervalues()) @@ -3220,6 +3230,16 @@ class CreateTable(_CreateDropBase): for column in element.columns ] + +class _DropView(_CreateDropBase): + """Semi-public 'DROP VIEW' construct. + + Used by the test suite for dialect-agnostic drops of views. + This object will eventually be part of a public "view" API. + + """ + __visit_name__ = "drop_view" + class CreateColumn(visitors.Visitable): """Represent a :class:`.Column` as rendered in a CREATE TABLE statement, via the :class:`.CreateTable` construct. |