Refs #24928 -- Added introspection support for PostgreSQL RangeField
This commit is contained in:
parent
0cbb6ac007
commit
a599ae6018
|
@ -18,6 +18,11 @@ class PostgresConfig(AppConfig):
|
|||
if conn.vendor == 'postgresql':
|
||||
conn.introspection.data_types_reverse.update({
|
||||
3802: 'django.contrib.postgresql.fields.JSONField',
|
||||
3904: 'django.contrib.postgresql.fields.IntegerRangeField',
|
||||
3906: 'django.contrib.postgresql.fields.FloatRangeField',
|
||||
3910: 'django.contrib.postgresql.fields.DateTimeRangeField',
|
||||
3912: 'django.contrib.postgresql.fields.DateRangeField',
|
||||
3926: 'django.contrib.postgresql.fields.BigIntegerRangeField',
|
||||
})
|
||||
if conn.connection is not None:
|
||||
register_type_handlers(conn)
|
||||
|
|
|
@ -123,8 +123,8 @@ Minor features
|
|||
operation installs the ``btree_gist`` extension to add support for operator
|
||||
classes that aren't built-in.
|
||||
|
||||
* :djadmin:`inspectdb` can now introspect ``JSONField``
|
||||
(``django.contrib.postgres`` must be in ``INSTALLED_APPS``).
|
||||
* :djadmin:`inspectdb` can now introspect ``JSONField`` and various
|
||||
``RangeField``\s (``django.contrib.postgres`` must be in ``INSTALLED_APPS``).
|
||||
|
||||
:mod:`django.contrib.redirects`
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
|
|
@ -24,3 +24,15 @@ class InspectDBTests(PostgreSQLTestCase):
|
|||
'postgres_tests_jsonmodel',
|
||||
['field = django.contrib.postgresql.fields.JSONField(blank=True, null=True)'],
|
||||
)
|
||||
|
||||
def test_range_fields(self):
|
||||
self.assertFieldsInModel(
|
||||
'postgres_tests_rangesmodel',
|
||||
[
|
||||
'ints = django.contrib.postgresql.fields.IntegerRangeField(blank=True, null=True)',
|
||||
'bigints = django.contrib.postgresql.fields.BigIntegerRangeField(blank=True, null=True)',
|
||||
'floats = django.contrib.postgresql.fields.FloatRangeField(blank=True, null=True)',
|
||||
'timestamps = django.contrib.postgresql.fields.DateTimeRangeField(blank=True, null=True)',
|
||||
'dates = django.contrib.postgresql.fields.DateRangeField(blank=True, null=True)',
|
||||
],
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue