Skip to content

Commit

Permalink
Refs django#373 -- Fixed CompositePKChecksTests.test_composite_pk_can…
Browse files Browse the repository at this point in the history
…not_include_generated_field() test crash on databases with no GeneratedField support.
  • Loading branch information
felixxm authored and sarahboyce committed Dec 2, 2024
1 parent d783a6f commit 81cf690
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tests/composite_pk/test_checks.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down Expand Up @@ -217,16 +217,18 @@ class Foo(models.Model):
],
)

@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(
Expand Down

0 comments on commit 81cf690

Please sign in to comment.