diff options
| author | Simon Charette <charette.s@gmail.com> | 2016-09-10 19:20:16 -0400 |
|---|---|---|
| committer | Simon Charette <charette.s@gmail.com> | 2016-09-12 20:07:35 -0400 |
| commit | 32c0d823e5316aa7d616a69996919b62748368cc (patch) | |
| tree | ee17f58d3e616d5477f42a09dad25f2af9d37123 /tests/postgres_tests/models.py | |
| parent | e07b18252baeb52bb0427007fc01ab0efee72bfd (diff) | |
Used a database feature to prevent the jsonb test model from being migrated.
Thanks Tim for the review.
Diffstat (limited to 'tests/postgres_tests/models.py')
| -rw-r--r-- | tests/postgres_tests/models.py | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/tests/postgres_tests/models.py b/tests/postgres_tests/models.py index 52dbc0335c..8913e60869 100644 --- a/tests/postgres_tests/models.py +++ b/tests/postgres_tests/models.py @@ -1,5 +1,5 @@ from django.core.serializers.json import DjangoJSONEncoder -from django.db import connection, models +from django.db import models from .fields import ( ArrayField, BigIntegerRangeField, DateRangeField, DateTimeRangeField, @@ -129,15 +129,12 @@ class RangeLookupsModel(PostgreSQLModel): date = models.DateField(blank=True, null=True) -# Only create this model for postgres >= 9.4 -if connection.vendor == 'postgresql' and connection.pg_version >= 90400: - class JSONModel(models.Model): - field = JSONField(blank=True, null=True) - field_custom = JSONField(blank=True, null=True, encoder=DjangoJSONEncoder) -else: - # create an object with this name so we don't have failing imports - class JSONModel(object): - pass +class JSONModel(models.Model): + field = JSONField(blank=True, null=True) + field_custom = JSONField(blank=True, null=True, encoder=DjangoJSONEncoder) + + class Meta: + required_db_features = ['has_jsonb_datatype'] class ArrayFieldSubclass(ArrayField): |
