diff options
| author | Marc Tamlyn <marc.tamlyn@gmail.com> | 2014-07-15 10:35:29 +0100 |
|---|---|---|
| committer | Marc Tamlyn <marc.tamlyn@gmail.com> | 2014-09-16 10:08:09 +0100 |
| commit | ed7821231b7dbf34a6c8ca65be3b9bcbda4a0703 (patch) | |
| tree | 98657032a61094eb7ac9c46d5db5bc12d25d1fa0 /django/db/backends/sqlite3 | |
| parent | 0d1561d19739e83cf20150585c9e26894b428bad (diff) | |
Fixed #19463 -- Added UUIDField
Uses native support in postgres, and char(32) on other backends.
Diffstat (limited to 'django/db/backends/sqlite3')
| -rw-r--r-- | django/db/backends/sqlite3/base.py | 10 | ||||
| -rw-r--r-- | django/db/backends/sqlite3/creation.py | 1 |
2 files changed, 10 insertions, 1 deletions
diff --git a/django/db/backends/sqlite3/base.py b/django/db/backends/sqlite3/base.py index 1da2542382..0e1070e6e5 100644 --- a/django/db/backends/sqlite3/base.py +++ b/django/db/backends/sqlite3/base.py @@ -8,8 +8,9 @@ from __future__ import unicode_literals import datetime import decimal -import warnings import re +import uuid +import warnings from django.conf import settings from django.db import utils @@ -273,6 +274,8 @@ class DatabaseOperations(BaseDatabaseOperations): converters.append(self.convert_timefield_value) elif internal_type == 'DecimalField': converters.append(self.convert_decimalfield_value) + elif internal_type == 'UUIDField': + converters.append(self.convert_uuidfield_value) return converters def convert_decimalfield_value(self, value, field): @@ -295,6 +298,11 @@ class DatabaseOperations(BaseDatabaseOperations): value = parse_time(value) return value + def convert_uuidfield_value(self, value, field): + if value is not None: + value = uuid.UUID(value) + return value + def bulk_insert_sql(self, fields, num_values): res = [] res.append("SELECT %s" % ", ".join( diff --git a/django/db/backends/sqlite3/creation.py b/django/db/backends/sqlite3/creation.py index 43b3924f4f..ea91c4a2b7 100644 --- a/django/db/backends/sqlite3/creation.py +++ b/django/db/backends/sqlite3/creation.py @@ -33,6 +33,7 @@ class DatabaseCreation(BaseDatabaseCreation): 'SmallIntegerField': 'smallint', 'TextField': 'text', 'TimeField': 'time', + 'UUIDField': 'char(32)', } data_types_suffix = { 'AutoField': 'AUTOINCREMENT', |
