From afea68ca51c20b726d3b97aaffdfe4e3b632e435 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Wed, 10 Nov 2021 00:21:36 -0500 Subject: [PATCH] Fixed DatabaseIntrospection.get_relations() docstring. The foreign keys are "in" the given table, not "to" it. --- django/db/backends/base/introspection.py | 5 ++--- django/db/backends/mysql/introspection.py | 2 +- django/db/backends/oracle/introspection.py | 2 +- django/db/backends/postgresql/introspection.py | 2 +- django/db/backends/sqlite3/introspection.py | 2 +- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/django/db/backends/base/introspection.py b/django/db/backends/base/introspection.py index c8b0e90873..8e9f5c751f 100644 --- a/django/db/backends/base/introspection.py +++ b/django/db/backends/base/introspection.py @@ -146,9 +146,8 @@ class BaseDatabaseIntrospection: def get_relations(self, cursor, table_name): """ - Return a dictionary of - {field_name: (field_name_other_table, other_table)} representing all - relationships to the given table. + Return a dictionary of {field_name: (field_name_other_table, other_table)} + representing all foreign keys in the given table. """ raise NotImplementedError( 'subclasses of BaseDatabaseIntrospection may require a ' diff --git a/django/db/backends/mysql/introspection.py b/django/db/backends/mysql/introspection.py index 2383c9ca1b..4e2fa3ce27 100644 --- a/django/db/backends/mysql/introspection.py +++ b/django/db/backends/mysql/introspection.py @@ -151,7 +151,7 @@ class DatabaseIntrospection(BaseDatabaseIntrospection): def get_relations(self, cursor, table_name): """ Return a dictionary of {field_name: (field_name_other_table, other_table)} - representing all relationships to the given table. + representing all foreign keys in the given table. """ constraints = self.get_key_columns(cursor, table_name) relations = {} diff --git a/django/db/backends/oracle/introspection.py b/django/db/backends/oracle/introspection.py index fa7a34ed0a..1fb26cba49 100644 --- a/django/db/backends/oracle/introspection.py +++ b/django/db/backends/oracle/introspection.py @@ -184,7 +184,7 @@ class DatabaseIntrospection(BaseDatabaseIntrospection): def get_relations(self, cursor, table_name): """ Return a dictionary of {field_name: (field_name_other_table, other_table)} - representing all relationships to the given table. + representing all foreign keys in the given table. """ table_name = table_name.upper() cursor.execute(""" diff --git a/django/db/backends/postgresql/introspection.py b/django/db/backends/postgresql/introspection.py index 4e35cb9e97..5a50ee68b7 100644 --- a/django/db/backends/postgresql/introspection.py +++ b/django/db/backends/postgresql/introspection.py @@ -119,7 +119,7 @@ class DatabaseIntrospection(BaseDatabaseIntrospection): def get_relations(self, cursor, table_name): """ Return a dictionary of {field_name: (field_name_other_table, other_table)} - representing all relationships to the given table. + representing all foreign keys in the given table. """ return {row[0]: (row[2], row[1]) for row in self.get_key_columns(cursor, table_name)} diff --git a/django/db/backends/sqlite3/introspection.py b/django/db/backends/sqlite3/introspection.py index ce097dbd72..f1f33579b9 100644 --- a/django/db/backends/sqlite3/introspection.py +++ b/django/db/backends/sqlite3/introspection.py @@ -115,7 +115,7 @@ class DatabaseIntrospection(BaseDatabaseIntrospection): def get_relations(self, cursor, table_name): """ Return a dictionary of {field_name: (field_name_other_table, other_table)} - representing all relationships to the given table. + representing all foreign keys in the given table. """ # Dictionary of relations to return relations = {}