diff options
| author | Jon Dufresne <jon.dufresne@gmail.com> | 2020-04-15 02:20:46 -0700 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-04-17 11:57:24 +0200 |
| commit | 75410228dfd16e49eb3c0ea30b59b4c0d2ea6b03 (patch) | |
| tree | cb9e6532b57cf60f8eaebcb3860241094e6a5588 /tests/backends/sqlite | |
| parent | 8005829bb9d9e0a14d73c9375bb55eb05daa46e1 (diff) | |
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.
Diffstat (limited to 'tests/backends/sqlite')
| -rw-r--r-- | tests/backends/sqlite/test_operations.py | 24 |
1 files changed, 2 insertions, 22 deletions
diff --git a/tests/backends/sqlite/test_operations.py b/tests/backends/sqlite/test_operations.py index 34c4d823da..0ee70061f8 100644 --- a/tests/backends/sqlite/test_operations.py +++ b/tests/backends/sqlite/test_operations.py @@ -14,7 +14,6 @@ class SQLiteOperationsTests(TestCase): connection.ops.sql_flush( no_style(), [Person._meta.db_table, Tag._meta.db_table], - [], ), [ 'DELETE FROM "backends_person";', @@ -26,7 +25,6 @@ class SQLiteOperationsTests(TestCase): statements = connection.ops.sql_flush( no_style(), [Person._meta.db_table, Tag._meta.db_table], - [], allow_cascade=True, ) self.assertEqual( @@ -47,16 +45,7 @@ class SQLiteOperationsTests(TestCase): 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, ), [ 'DELETE FROM "backends_person";', @@ -69,16 +58,7 @@ class SQLiteOperationsTests(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, ) self.assertEqual( |
