summaryrefslogtreecommitdiff
path: root/django/db/backends/sqlite3
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2009-01-15 11:06:34 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2009-01-15 11:06:34 +0000
commitcc4e4d9aee0b3ebfb45bee01aec79edc9e144c78 (patch)
tree2cdba846a105d406ecceff2c02e071c50502d487 /django/db/backends/sqlite3
parent50a293a0c31e7325ebd520338f9c8881f951d8a7 (diff)
Fixed #3566 -- Added support for aggregation to the ORM. See the documentation for details on usage.
Many thanks to: * Nicolas Lara, who worked on this feature during the 2008 Google Summer of Code. * Alex Gaynor for his help debugging and fixing a number of issues. * Justin Bronn for his help integrating with contrib.gis. * Karen Tracey for her help with cross-platform testing. * Ian Kelly for his help testing and fixing Oracle support. * Malcolm Tredinnick for his invaluable review notes. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9742 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db/backends/sqlite3')
-rw-r--r--django/db/backends/sqlite3/base.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/django/db/backends/sqlite3/base.py b/django/db/backends/sqlite3/base.py
index 15b0e983ad..071d421b58 100644
--- a/django/db/backends/sqlite3/base.py
+++ b/django/db/backends/sqlite3/base.py
@@ -10,7 +10,7 @@ from django.db.backends import *
from django.db.backends.sqlite3.client import DatabaseClient
from django.db.backends.sqlite3.creation import DatabaseCreation
from django.db.backends.sqlite3.introspection import DatabaseIntrospection
-from django.utils.safestring import SafeString
+from django.utils.safestring import SafeString
try:
try:
@@ -102,6 +102,26 @@ class DatabaseOperations(BaseDatabaseOperations):
second = '%s-12-31 23:59:59.999999'
return [first % value, second % value]
+ def convert_values(self, value, field):
+ """SQLite returns floats when it should be returning decimals,
+ and gets dates and datetimes wrong.
+ For consistency with other backends, coerce when required.
+ """
+ internal_type = field.get_internal_type()
+ if internal_type == 'DecimalField':
+ return util.typecast_decimal(field.format_number(value))
+ elif internal_type and internal_type.endswith('IntegerField') or internal_type == 'AutoField':
+ return int(value)
+ elif internal_type == 'DateField':
+ return util.typecast_date(value)
+ elif internal_type == 'DateTimeField':
+ return util.typecast_timestamp(value)
+ elif internal_type == 'TimeField':
+ return util.typecast_time(value)
+
+ # No field, or the field isn't known to be a decimal or integer
+ return value
+
class DatabaseWrapper(BaseDatabaseWrapper):
# SQLite requires LIKE statements to include an ESCAPE clause if the value