summaryrefslogtreecommitdiff
path: root/django/db/backends/__init__.py
diff options
context:
space:
mode:
authorMarc Tamlyn <marc.tamlyn@gmail.com>2014-08-12 13:08:40 +0100
committerMarc Tamlyn <marc.tamlyn@gmail.com>2014-09-03 20:36:03 +0100
commite9103402c0fa873aea58a6a11dba510cd308cb84 (patch)
tree947a946de6d7354f22e8c5ec7a98ecc37c98eb08 /django/db/backends/__init__.py
parent89559bcfb096ccc625e0e9ab41e2136fcb32a514 (diff)
Fixed #18757, #14462, #21565 -- Reworked database-python type conversions
Complete rework of translating data values from database Deprecation of SubfieldBase, removal of resolve_columns and convert_values in favour of a more general converter based approach and public API Field.from_db_value(). Now works seamlessly with aggregation, .values() and raw queries. Thanks to akaariai in particular for extensive advice and inspiration, also to shaib, manfre and timograham for their reviews.
Diffstat (limited to 'django/db/backends/__init__.py')
-rw-r--r--django/db/backends/__init__.py19
1 files changed, 6 insertions, 13 deletions
diff --git a/django/db/backends/__init__.py b/django/db/backends/__init__.py
index ca58bce3c0..70e024a19b 100644
--- a/django/db/backends/__init__.py
+++ b/django/db/backends/__init__.py
@@ -1190,20 +1190,13 @@ class BaseDatabaseOperations(object):
second = timezone.make_aware(second, tz)
return [first, second]
- def convert_values(self, value, field):
- """
- Coerce the value returned by the database backend into a consistent type
- that is compatible with the field type.
+ def get_db_converters(self, internal_type):
+ """Get a list of functions needed to convert field data.
+
+ Some field types on some backends do not provide data in the correct
+ format, this is the hook for coverter functions.
"""
- if value is None or field is None:
- return value
- internal_type = field.get_internal_type()
- if internal_type == 'FloatField':
- return float(value)
- elif (internal_type and (internal_type.endswith('IntegerField')
- or internal_type == 'AutoField')):
- return int(value)
- return value
+ return []
def check_aggregate_support(self, aggregate_func):
"""Check that the backend supports the provided aggregate