From 4fba321a457e52df77d0b512d043019e9f6b0bc9 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Fri, 29 Jun 2018 15:43:53 +0100 Subject: [PATCH] Fixed #29480 -- Made MySQL backend retrieve constraint columns in their defined order. --- django/db/backends/mysql/introspection.py | 1 + 1 file changed, 1 insertion(+) diff --git a/django/db/backends/mysql/introspection.py b/django/db/backends/mysql/introspection.py index 9520e890ea..56280b6fe5 100644 --- a/django/db/backends/mysql/introspection.py +++ b/django/db/backends/mysql/introspection.py @@ -160,6 +160,7 @@ class DatabaseIntrospection(BaseDatabaseIntrospection): WHERE kc.table_schema = DATABASE() AND kc.table_name = %s + ORDER BY kc.`ordinal_position` """ cursor.execute(name_query, [table_name]) for constraint, column, ref_table, ref_column in cursor.fetchall():