From 3ea7167bb599536b48422d1fa841a2d378c98a4a Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Wed, 20 Jul 2016 09:01:57 +0200 Subject: [PATCH] Refs #24928 -- Added introspection support for UUIDField --- django/db/backends/postgresql/introspection.py | 1 + tests/inspectdb/models.py | 1 + tests/inspectdb/tests.py | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/django/db/backends/postgresql/introspection.py b/django/db/backends/postgresql/introspection.py index 103adb50f66f..aa37c8d01ea3 100644 --- a/django/db/backends/postgresql/introspection.py +++ b/django/db/backends/postgresql/introspection.py @@ -30,6 +30,7 @@ class DatabaseIntrospection(BaseDatabaseIntrospection): 1184: 'DateTimeField', 1266: 'TimeField', 1700: 'DecimalField', + 2950: 'UUIDField', } ignored_tables = [] diff --git a/tests/inspectdb/models.py b/tests/inspectdb/models.py index ff2fbd6c09ae..4b17c0444f70 100644 --- a/tests/inspectdb/models.py +++ b/tests/inspectdb/models.py @@ -67,6 +67,7 @@ class ColumnTypes(models.Model): text_field = models.TextField() time_field = models.TimeField() url_field = models.URLField() + uuid_field = models.UUIDField() class UniqueTogether(models.Model): diff --git a/tests/inspectdb/tests.py b/tests/inspectdb/tests.py index 37ba8db89c01..60942353d90a 100644 --- a/tests/inspectdb/tests.py +++ b/tests/inspectdb/tests.py @@ -87,6 +87,11 @@ def test_field_types(self): if (connection.features.can_introspect_max_length and not connection.features.interprets_empty_strings_as_nulls): assertFieldType('url_field', "models.CharField(max_length=200)") + if connection.features.has_native_uuid_field: + assertFieldType('uuid_field', "models.UUIDField()") + elif (connection.features.can_introspect_max_length and + not connection.features.interprets_empty_strings_as_nulls): + assertFieldType('uuid_field', "models.CharField(max_length=32)") def test_number_field_types(self): """Test introspection of various Django field types"""