@@ -607,8 +607,17 @@ def visit_drop_table(self, drop_table, **kw):
607607 constrs = ""
608608 for cons in drop_table .element .constraints :
609609 if isinstance (cons , ForeignKeyConstraint ) and cons .name :
610+ effective_schema = self .preparer .schema_for_object (drop_table .element )
611+ if effective_schema :
612+ table = (
613+ f"{ self .preparer .quote_schema (effective_schema )} "
614+ "."
615+ f"{ self .preparer .quote (drop_table .element .name )} "
616+ )
617+ else :
618+ table = self .preparer .quote (drop_table .element .name )
610619 constrs += "ALTER TABLE {table} DROP CONSTRAINT {constr};" .format (
611- table = drop_table . element . name ,
620+ table = table ,
612621 constr = self .preparer .quote (cons .name ),
613622 )
614623
@@ -1472,10 +1481,12 @@ def get_multi_foreign_keys(
14721481 )
14731482 FROM information_schema.table_constraints AS tc
14741483 JOIN information_schema.constraint_column_usage AS ccu
1475- USING (table_catalog, table_schema, constraint_name)
1484+ ON ccu.table_catalog = tc.table_catalog
1485+ and ccu.constraint_schema = tc.table_schema
1486+ and ccu.constraint_name = tc.constraint_name
14761487 JOIN information_schema.constraint_table_usage AS ctu
14771488 ON ctu.table_catalog = tc.table_catalog
1478- and ctu.table_schema = tc.table_schema
1489+ and ctu.constraint_schema = tc.table_schema
14791490 and ctu.constraint_name = tc.constraint_name
14801491 JOIN information_schema.key_column_usage AS kcu
14811492 ON kcu.table_catalog = tc.table_catalog
0 commit comments