From 68a8996bdfce2d191decd7b1c1a2b9fdea8e4b2f Mon Sep 17 00:00:00 2001 From: John Whitman Date: Mon, 28 Aug 2023 14:16:38 -0400 Subject: Fixed #34799 -- Made MySQL introspection skip cross-database relations. --- django/db/backends/mysql/introspection.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'django') diff --git a/django/db/backends/mysql/introspection.py b/django/db/backends/mysql/introspection.py index a1ee51a692..ea1d0aa187 100644 --- a/django/db/backends/mysql/introspection.py +++ b/django/db/backends/mysql/introspection.py @@ -198,6 +198,7 @@ class DatabaseIntrospection(BaseDatabaseIntrospection): FROM information_schema.key_column_usage WHERE table_name = %s AND table_schema = DATABASE() + AND referenced_table_schema = DATABASE() AND referenced_table_name IS NOT NULL AND referenced_column_name IS NOT NULL """, @@ -257,6 +258,10 @@ class DatabaseIntrospection(BaseDatabaseIntrospection): information_schema.table_constraints AS c WHERE kc.table_schema = DATABASE() AND + ( + kc.referenced_table_schema = DATABASE() OR + kc.referenced_table_schema IS NULL + ) AND c.table_schema = kc.table_schema AND c.constraint_name = kc.constraint_name AND c.constraint_type != 'CHECK' AND -- cgit v1.3