Skip to content

Commit

Permalink
Refs #24928 -- Added introspection support for UUIDField
Browse files Browse the repository at this point in the history
  • Loading branch information
claudep committed Jul 20, 2016
1 parent 271bfe6 commit 3ea7167
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions django/db/backends/postgresql/introspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
1184: 'DateTimeField',
1266: 'TimeField',
1700: 'DecimalField',
2950: 'UUIDField',
}

ignored_tables = []
Expand Down
1 change: 1 addition & 0 deletions tests/inspectdb/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
5 changes: 5 additions & 0 deletions tests/inspectdb/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down

0 comments on commit 3ea7167

Please sign in to comment.