(self, metadata)
| 1076 | self.memo = {} |
| 1077 | |
| 1078 | def visit_metadata(self, metadata): |
| 1079 | if self.tables is not None: |
| 1080 | tables = self.tables |
| 1081 | else: |
| 1082 | tables = list(metadata.tables.values()) |
| 1083 | |
| 1084 | try: |
| 1085 | unsorted_tables = [t for t in tables if self._can_drop_table(t)] |
| 1086 | collection = list( |
| 1087 | reversed( |
| 1088 | sort_tables_and_constraints( |
| 1089 | unsorted_tables, |
| 1090 | filter_fn=lambda constraint: ( |
| 1091 | False |
| 1092 | if not self.dialect.supports_alter |
| 1093 | or constraint.name is None |
| 1094 | else None |
| 1095 | ), |
| 1096 | ) |
| 1097 | ) |
| 1098 | ) |
| 1099 | except exc.CircularDependencyError as err2: |
| 1100 | if not self.dialect.supports_alter: |
| 1101 | util.warn( |
| 1102 | "Can't sort tables for DROP; an " |
| 1103 | "unresolvable foreign key " |
| 1104 | "dependency exists between tables: %s; and backend does " |
| 1105 | "not support ALTER. To restore at least a partial sort, " |
| 1106 | "apply use_alter=True to ForeignKey and " |
| 1107 | "ForeignKeyConstraint " |
| 1108 | "objects involved in the cycle to mark these as known " |
| 1109 | "cycles that will be ignored." |
| 1110 | % (", ".join(sorted([t.fullname for t in err2.cycles]))) |
| 1111 | ) |
| 1112 | collection = [(t, ()) for t in unsorted_tables] |
| 1113 | else: |
| 1114 | raise exc.CircularDependencyError( |
| 1115 | err2.args[0], |
| 1116 | err2.cycles, |
| 1117 | err2.edges, |
| 1118 | msg="Can't sort tables for DROP; an " |
| 1119 | "unresolvable foreign key " |
| 1120 | "dependency exists between tables: %s. Please ensure " |
| 1121 | "that the ForeignKey and ForeignKeyConstraint objects " |
| 1122 | "involved in the cycle have " |
| 1123 | "names so that they can be dropped using " |
| 1124 | "DROP CONSTRAINT." |
| 1125 | % (", ".join(sorted([t.fullname for t in err2.cycles]))), |
| 1126 | ) from err2 |
| 1127 | |
| 1128 | seq_coll = [ |
| 1129 | s |
| 1130 | for s in metadata._sequences.values() |
| 1131 | if self._can_drop_sequence(s) |
| 1132 | ] |
| 1133 | |
| 1134 | event_collection = [t for (t, fks) in collection if t is not None] |
| 1135 |
nothing calls this directly
no test coverage detected