mirror of
https://github.com/django/django.git
synced 2025-07-18 02:35:16 +00:00
Refs #24928 -- Added introspection support for PostgreSQL JSONField
Thanks Adam Johnson and Tim Graham for the reviews.
This commit is contained in:
parent
ffbee67f8e
commit
0cbb6ac007
4 changed files with 38 additions and 3 deletions
26
tests/postgres_tests/test_introspection.py
Normal file
26
tests/postgres_tests/test_introspection.py
Normal file
|
@ -0,0 +1,26 @@
|
|||
from io import StringIO
|
||||
|
||||
from django.core.management import call_command
|
||||
from django.test.utils import modify_settings
|
||||
|
||||
from . import PostgreSQLTestCase
|
||||
|
||||
|
||||
@modify_settings(INSTALLED_APPS={'append': 'django.contrib.postgres'})
|
||||
class InspectDBTests(PostgreSQLTestCase):
|
||||
def assertFieldsInModel(self, model, field_outputs):
|
||||
out = StringIO()
|
||||
call_command(
|
||||
'inspectdb',
|
||||
table_name_filter=lambda tn: tn.startswith(model),
|
||||
stdout=out,
|
||||
)
|
||||
output = out.getvalue()
|
||||
for field_output in field_outputs:
|
||||
self.assertIn(field_output, output)
|
||||
|
||||
def test_json_field(self):
|
||||
self.assertFieldsInModel(
|
||||
'postgres_tests_jsonmodel',
|
||||
['field = django.contrib.postgresql.fields.JSONField(blank=True, null=True)'],
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue