summaryrefslogtreecommitdiff
path: root/tests/postgres_tests/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/postgres_tests/models.py')
-rw-r--r--tests/postgres_tests/models.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/tests/postgres_tests/models.py b/tests/postgres_tests/models.py
index aafd529443..329a91c951 100644
--- a/tests/postgres_tests/models.py
+++ b/tests/postgres_tests/models.py
@@ -2,7 +2,7 @@ from django.db import connection, models
from .fields import (
ArrayField, BigIntegerRangeField, DateRangeField, DateTimeRangeField,
- FloatRangeField, HStoreField, IntegerRangeField,
+ FloatRangeField, HStoreField, IntegerRangeField, JSONField,
)
@@ -52,7 +52,7 @@ class TextFieldModel(models.Model):
field = models.TextField()
-# Only create this model for databases which support it
+# Only create this model for postgres >= 9.2
if connection.vendor == 'postgresql' and connection.pg_version >= 90200:
class RangesModel(PostgreSQLModel):
ints = IntegerRangeField(blank=True, null=True)
@@ -66,6 +66,16 @@ else:
pass
+# 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)
+else:
+ # create an object with this name so we don't have failing imports
+ class JSONModel(object):
+ pass
+
+
class ArrayFieldSubclass(ArrayField):
def __init__(self, *args, **kwargs):
super(ArrayFieldSubclass, self).__init__(models.IntegerField())