From 75410228dfd16e49eb3c0ea30b59b4c0d2ea6b03 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Wed, 15 Apr 2020 02:20:46 -0700 Subject: Fixed #31473 -- Made sql_flush() use RESTART IDENTITY to reset sequences on PostgreSQL. The sql_flush() positional argument sequences is replaced by the boolean keyword-only argument reset_sequences. This ensures that the old function signature can't be used by mistake when upgrading Django. When the new argument is True, the sequences of the truncated tables will reset. Using a single boolean value, rather than a list, allows making a binary yes/no choice as to whether to reset all sequences rather than a working on a completely different set. --- tests/backends/oracle/test_operations.py | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) (limited to 'tests/backends/oracle') diff --git a/tests/backends/oracle/test_operations.py b/tests/backends/oracle/test_operations.py index 97760ecbfe..7722744ecc 100644 --- a/tests/backends/oracle/test_operations.py +++ b/tests/backends/oracle/test_operations.py @@ -31,7 +31,6 @@ class OperationsTests(unittest.TestCase): statements = connection.ops.sql_flush( no_style(), [Person._meta.db_table, Tag._meta.db_table], - [], ) # The tables and constraints are processed in an unordered set. self.assertEqual( @@ -56,7 +55,6 @@ class OperationsTests(unittest.TestCase): statements = connection.ops.sql_flush( no_style(), [Person._meta.db_table, Tag._meta.db_table], - [], allow_cascade=True, ) # The tables and constraints are processed in an unordered set. @@ -83,16 +81,7 @@ class OperationsTests(unittest.TestCase): statements = connection.ops.sql_flush( no_style(), [Person._meta.db_table, Tag._meta.db_table], - [ - { - 'table': Person._meta.db_table, - 'column': Person._meta.pk.db_column, - }, - { - 'table': Tag._meta.db_table, - 'column': Tag._meta.pk.db_column, - }, - ], + reset_sequences=True, ) # The tables and constraints are processed in an unordered set. self.assertEqual( @@ -121,16 +110,7 @@ class OperationsTests(unittest.TestCase): statements = connection.ops.sql_flush( no_style(), [Person._meta.db_table, Tag._meta.db_table], - [ - { - 'table': Person._meta.db_table, - 'column': Person._meta.pk.db_column, - }, - { - 'table': Tag._meta.db_table, - 'column': Tag._meta.pk.db_column, - }, - ], + reset_sequences=True, allow_cascade=True, ) # The tables and constraints are processed in an unordered set. @@ -153,6 +133,7 @@ class OperationsTests(unittest.TestCase): '"BACKENDS__PERSON_ID_1DD5E829_F";', ) # Sequences. - self.assertEqual(len(statements[5:]), 2) + self.assertEqual(len(statements[5:]), 3) self.assertIn('BACKENDS_PERSON_SQ', statements[5]) - self.assertIn('BACKENDS_TAG_SQ', statements[6]) + self.assertIn('BACKENDS_VERYLONGMODELN7BE2_SQ', statements[6]) + self.assertIn('BACKENDS_TAG_SQ', statements[7]) -- cgit v1.3