summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorFlorian Apolloner <florian@apolloner.eu>2022-03-24 16:46:19 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-04-13 21:51:51 +0200
commit2eea361eff58dd98c409c5227064b901f41bd0d6 (patch)
treeb551c3b45c3d0f133d88ef346ec1657f937d2892 /tests
parent62ffc9883afdc0a9f9674702661062508230d7bf (diff)
Fixed #30511 -- Used identity columns instead of serials on PostgreSQL.
Diffstat (limited to 'tests')
-rw-r--r--tests/backends/postgresql/test_introspection.py15
-rw-r--r--tests/schema/tests.py14
2 files changed, 17 insertions, 12 deletions
diff --git a/tests/backends/postgresql/test_introspection.py b/tests/backends/postgresql/test_introspection.py
index dc95d6ad23..2dfb7514d6 100644
--- a/tests/backends/postgresql/test_introspection.py
+++ b/tests/backends/postgresql/test_introspection.py
@@ -27,3 +27,18 @@ class DatabaseSequenceTests(TestCase):
seqs,
[{"table": Person._meta.db_table, "column": "id", "name": "pers_seq"}],
)
+
+ def test_get_sequences_old_serial(self):
+ with connection.cursor() as cursor:
+ cursor.execute("CREATE TABLE testing (serial_field SERIAL);")
+ seqs = connection.introspection.get_sequences(cursor, "testing")
+ self.assertEqual(
+ seqs,
+ [
+ {
+ "table": "testing",
+ "column": "serial_field",
+ "name": "testing_serial_field_seq",
+ }
+ ],
+ )
diff --git a/tests/schema/tests.py b/tests/schema/tests.py
index c758db8bc8..049e604480 100644
--- a/tests/schema/tests.py
+++ b/tests/schema/tests.py
@@ -1570,11 +1570,7 @@ class SchemaTests(TransactionTestCase):
Author.objects.create(name="Foo")
Author.objects.create(name="Bar")
- def test_alter_autofield_pk_to_bigautofield_pk_sequence_owner(self):
- """
- Converting an implicit PK to BigAutoField(primary_key=True) should keep
- a sequence owner on PostgreSQL.
- """
+ def test_alter_autofield_pk_to_bigautofield_pk(self):
with connection.schema_editor() as editor:
editor.create_model(Author)
old_field = Author._meta.get_field("id")
@@ -1591,14 +1587,9 @@ class SchemaTests(TransactionTestCase):
)
if sequence_reset_sqls:
cursor.execute(sequence_reset_sqls[0])
- # Fail on PostgreSQL if sequence is missing an owner.
self.assertIsNotNone(Author.objects.create(name="Bar"))
- def test_alter_autofield_pk_to_smallautofield_pk_sequence_owner(self):
- """
- Converting an implicit PK to SmallAutoField(primary_key=True) should
- keep a sequence owner on PostgreSQL.
- """
+ def test_alter_autofield_pk_to_smallautofield_pk(self):
with connection.schema_editor() as editor:
editor.create_model(Author)
old_field = Author._meta.get_field("id")
@@ -1615,7 +1606,6 @@ class SchemaTests(TransactionTestCase):
)
if sequence_reset_sqls:
cursor.execute(sequence_reset_sqls[0])
- # Fail on PostgreSQL if sequence is missing an owner.
self.assertIsNotNone(Author.objects.create(name="Bar"))
def test_alter_int_pk_to_autofield_pk(self):