(self, metadata)
| 1537 | self.memo = {} |
| 1538 | |
| 1539 | def visit_metadata(self, metadata): |
| 1540 | if self.tables is not None: |
| 1541 | tables = self.tables |
| 1542 | else: |
| 1543 | tables = list(metadata.tables.values()) |
| 1544 | |
| 1545 | try: |
| 1546 | unsorted_tables = [t for t in tables if self._can_drop_table(t)] |
| 1547 | collection = list( |
| 1548 | reversed( |
| 1549 | sort_tables_and_constraints( |
| 1550 | unsorted_tables, |
| 1551 | filter_fn=lambda constraint: ( |
| 1552 | False |
| 1553 | if not self.dialect.supports_alter |
| 1554 | or constraint.name is None |
| 1555 | else None |
| 1556 | ), |
| 1557 | ) |
| 1558 | ) |
| 1559 | ) |
| 1560 | except exc.CircularDependencyError as err2: |
| 1561 | if not self.dialect.supports_alter: |
| 1562 | util.warn( |
| 1563 | "Can't sort tables for DROP; an " |
| 1564 | "unresolvable foreign key " |
| 1565 | "dependency exists between tables: %s; and backend does " |
| 1566 | "not support ALTER. To restore at least a partial sort, " |
| 1567 | "apply use_alter=True to ForeignKey and " |
| 1568 | "ForeignKeyConstraint " |
| 1569 | "objects involved in the cycle to mark these as known " |
| 1570 | "cycles that will be ignored." |
| 1571 | % (", ".join(sorted([t.fullname for t in err2.cycles]))) |
| 1572 | ) |
| 1573 | collection = [(t, ()) for t in unsorted_tables] |
| 1574 | else: |
| 1575 | raise exc.CircularDependencyError( |
| 1576 | err2.args[0], |
| 1577 | err2.cycles, |
| 1578 | err2.edges, |
| 1579 | msg="Can't sort tables for DROP; an " |
| 1580 | "unresolvable foreign key " |
| 1581 | "dependency exists between tables: %s. Please ensure " |
| 1582 | "that the ForeignKey and ForeignKeyConstraint objects " |
| 1583 | "involved in the cycle have " |
| 1584 | "names so that they can be dropped using " |
| 1585 | "DROP CONSTRAINT." |
| 1586 | % (", ".join(sorted([t.fullname for t in err2.cycles]))), |
| 1587 | ) from err2 |
| 1588 | |
| 1589 | seq_coll = [ |
| 1590 | s |
| 1591 | for s in metadata._sequences.values() |
| 1592 | if self._can_drop_sequence(s) |
| 1593 | ] |
| 1594 | |
| 1595 | event_collection = [t for (t, fks) in collection if t is not None] |
| 1596 |
nothing calls this directly
no test coverage detected