mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +00:00
Refs #373 -- Fixed CompositePKChecksTests.test_composite_pk_cannot_include_generated_field() test crash on databases with no GeneratedField support.
This commit is contained in:
parent
d783a6f1c0
commit
81cf690111
@ -1,7 +1,7 @@
|
|||||||
from django.core import checks
|
from django.core import checks
|
||||||
from django.db import connection, models
|
from django.db import connection, models
|
||||||
from django.db.models import F
|
from django.db.models import F
|
||||||
from django.test import TestCase
|
from django.test import TestCase, skipUnlessAnyDBFeature
|
||||||
from django.test.utils import isolate_apps
|
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):
|
def test_composite_pk_cannot_include_generated_field(self):
|
||||||
is_oracle = connection.vendor == "oracle"
|
|
||||||
|
|
||||||
class Foo(models.Model):
|
class Foo(models.Model):
|
||||||
pk = models.CompositePrimaryKey("id", "foo")
|
pk = models.CompositePrimaryKey("id", "foo")
|
||||||
id = models.IntegerField()
|
id = models.IntegerField()
|
||||||
foo = models.GeneratedField(
|
foo = models.GeneratedField(
|
||||||
expression=F("id"),
|
expression=F("id"),
|
||||||
output_field=models.IntegerField(),
|
output_field=models.IntegerField(),
|
||||||
db_persist=not is_oracle,
|
db_persist=connection.features.supports_stored_generated_columns,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
|
Loading…
Reference in New Issue
Block a user