2015-04-04 16:10:26 +00:00
|
|
|
"""
|
|
|
|
Indirection layer for PostgreSQL-specific fields, so the tests don't fail when
|
|
|
|
run with a backend other than PostgreSQL.
|
|
|
|
"""
|
|
|
|
from django.db import models
|
|
|
|
|
|
|
|
try:
|
|
|
|
from django.contrib.postgres.fields import (
|
|
|
|
ArrayField, BigIntegerRangeField, DateRangeField, DateTimeRangeField,
|
2015-05-30 21:13:58 +00:00
|
|
|
FloatRangeField, HStoreField, IntegerRangeField, JSONField,
|
2015-04-04 16:10:26 +00:00
|
|
|
)
|
2015-05-31 21:45:03 +00:00
|
|
|
from django.contrib.postgres.search import SearchVectorField
|
2015-04-04 16:10:26 +00:00
|
|
|
except ImportError:
|
|
|
|
class DummyArrayField(models.Field):
|
|
|
|
def __init__(self, base_field, size=None, **kwargs):
|
|
|
|
super(DummyArrayField, self).__init__(**kwargs)
|
|
|
|
|
|
|
|
def deconstruct(self):
|
|
|
|
name, path, args, kwargs = super(DummyArrayField, self).deconstruct()
|
|
|
|
kwargs.update({
|
|
|
|
'base_field': '',
|
|
|
|
'size': 1,
|
|
|
|
})
|
|
|
|
return name, path, args, kwargs
|
|
|
|
|
2016-08-11 19:05:52 +00:00
|
|
|
class DummyJSONField(models.Field):
|
|
|
|
def __init__(self, encoder=None, **kwargs):
|
|
|
|
super(DummyJSONField, self).__init__(**kwargs)
|
|
|
|
|
2015-04-04 16:10:26 +00:00
|
|
|
ArrayField = DummyArrayField
|
|
|
|
BigIntegerRangeField = models.Field
|
|
|
|
DateRangeField = models.Field
|
|
|
|
DateTimeRangeField = models.Field
|
|
|
|
FloatRangeField = models.Field
|
|
|
|
HStoreField = models.Field
|
|
|
|
IntegerRangeField = models.Field
|
2016-08-11 19:05:52 +00:00
|
|
|
JSONField = DummyJSONField
|
2015-05-31 21:45:03 +00:00
|
|
|
SearchVectorField = models.Field
|