From 18d4eac7fce6dfab6149ec7aba72f3c765b5722c Mon Sep 17 00:00:00 2001 From: Ravindar Sharma Date: Sun, 12 Jul 2020 18:31:06 +0530 Subject: Fixed #31731 -- Removed unreachable code for resetting sequences of auto-created m2m tables in sequence_reset_sql(). Unreachable because f.remote_field.through is truthy for all m2m fields. Resetting sequences of auto-created m2m tables in sequence_reset_sql() is also unnecessary: - in sqlsequencereset since c39ec6dccb389fbb4047e44f5247e18bb76ae598 because auto-created tables are included in model_list, - in loaddata because there is no it need to reset sequences for models not loaded directly. - in create_default_site() because it doesn't have m2m fields. --- django/db/backends/postgresql/operations.py | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'django/db/backends/postgresql/operations.py') diff --git a/django/db/backends/postgresql/operations.py b/django/db/backends/postgresql/operations.py index 51374cb3bb..a3442231af 100644 --- a/django/db/backends/postgresql/operations.py +++ b/django/db/backends/postgresql/operations.py @@ -185,21 +185,6 @@ class DatabaseOperations(BaseDatabaseOperations): ) ) break # Only one AutoField is allowed per model, so don't bother continuing. - for f in model._meta.many_to_many: - if not f.remote_field.through: - output.append( - "%s setval(pg_get_serial_sequence('%s','%s'), " - "coalesce(max(%s), 1), max(%s) %s null) %s %s;" % ( - style.SQL_KEYWORD('SELECT'), - style.SQL_TABLE(qn(f.m2m_db_table())), - style.SQL_FIELD('id'), - style.SQL_FIELD(qn('id')), - style.SQL_FIELD(qn('id')), - style.SQL_KEYWORD('IS NOT'), - style.SQL_KEYWORD('FROM'), - style.SQL_TABLE(qn(f.m2m_db_table())) - ) - ) return output def prep_for_iexact_query(self, x): -- cgit v1.2.1