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 c39ec6dccb
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.
This commit is contained in:
parent
5ef6f62634
commit
18d4eac7fc
|
@ -494,18 +494,6 @@ END;
|
|||
# Only one AutoField is allowed per model, so don't
|
||||
# continue to loop
|
||||
break
|
||||
for f in model._meta.many_to_many:
|
||||
if not f.remote_field.through:
|
||||
no_autofield_sequence_name = self._get_no_autofield_sequence_name(f.m2m_db_table())
|
||||
table = self.quote_name(f.m2m_db_table())
|
||||
column = self.quote_name('id')
|
||||
output.append(query % {
|
||||
'no_autofield_sequence_name': no_autofield_sequence_name,
|
||||
'table': table,
|
||||
'column': column,
|
||||
'table_name': strip_quotes(table),
|
||||
'column_name': 'ID',
|
||||
})
|
||||
return output
|
||||
|
||||
def start_transaction_sql(self):
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue