Skip to content

Commit 1925ac8

Browse files
committed
Merge branch 'main' into support-commit-timestamps
2 parents 70744d4 + 9aea129 commit 1925ac8

File tree

3 files changed

+224
-95
lines changed

3 files changed

+224
-95
lines changed

google/cloud/sqlalchemy_spanner/sqlalchemy_spanner.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -612,8 +612,17 @@ def visit_drop_table(self, drop_table, **kw):
612612
constrs = ""
613613
for cons in drop_table.element.constraints:
614614
if isinstance(cons, ForeignKeyConstraint) and cons.name:
615+
effective_schema = self.preparer.schema_for_object(drop_table.element)
616+
if effective_schema:
617+
table = (
618+
f"{self.preparer.quote_schema(effective_schema)}"
619+
"."
620+
f"{self.preparer.quote(drop_table.element.name)}"
621+
)
622+
else:
623+
table = self.preparer.quote(drop_table.element.name)
615624
constrs += "ALTER TABLE {table} DROP CONSTRAINT {constr};".format(
616-
table=drop_table.element.name,
625+
table=table,
617626
constr=self.preparer.quote(cons.name),
618627
)
619628

@@ -1477,10 +1486,12 @@ def get_multi_foreign_keys(
14771486
)
14781487
FROM information_schema.table_constraints AS tc
14791488
JOIN information_schema.constraint_column_usage AS ccu
1480-
USING (table_catalog, table_schema, constraint_name)
1489+
ON ccu.table_catalog = tc.table_catalog
1490+
and ccu.constraint_schema = tc.table_schema
1491+
and ccu.constraint_name = tc.constraint_name
14811492
JOIN information_schema.constraint_table_usage AS ctu
14821493
ON ctu.table_catalog = tc.table_catalog
1483-
and ctu.table_schema = tc.table_schema
1494+
and ctu.constraint_schema = tc.table_schema
14841495
and ctu.constraint_name = tc.constraint_name
14851496
JOIN information_schema.key_column_usage AS kcu
14861497
ON kcu.table_catalog = tc.table_catalog

0 commit comments

Comments
 (0)