From 81cf690111e49b9cf9d8a3b8a71767f3c8685d5b Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Fri, 29 Nov 2024 21:34:39 +0100 Subject: [PATCH] Refs #373 -- Fixed CompositePKChecksTests.test_composite_pk_cannot_include_generated_field() test crash on databases with no GeneratedField support. --- tests/composite_pk/test_checks.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/composite_pk/test_checks.py b/tests/composite_pk/test_checks.py index 02a162c31d..58b580ca85 100644 --- a/tests/composite_pk/test_checks.py +++ b/tests/composite_pk/test_checks.py @@ -1,7 +1,7 @@ from django.core import checks from django.db import connection, models from django.db.models import F -from django.test import TestCase +from django.test import TestCase, skipUnlessAnyDBFeature from django.test.utils import isolate_apps @@ -217,16 +217,18 @@ class CompositePKChecksTests(TestCase): ], ) + @skipUnlessAnyDBFeature( + "supports_virtual_generated_columns", + "supports_stored_generated_columns", + ) def test_composite_pk_cannot_include_generated_field(self): - is_oracle = connection.vendor == "oracle" - class Foo(models.Model): pk = models.CompositePrimaryKey("id", "foo") id = models.IntegerField() foo = models.GeneratedField( expression=F("id"), output_field=models.IntegerField(), - db_persist=not is_oracle, + db_persist=connection.features.supports_stored_generated_columns, ) self.assertEqual(