diff options
| author | Marc Tamlyn <marc.tamlyn@gmail.com> | 2014-07-24 13:57:24 +0100 |
|---|---|---|
| committer | Marc Tamlyn <marc.tamlyn@gmail.com> | 2014-12-20 18:28:29 +0000 |
| commit | 57554442fe3e209c135e15dda4ea45123e579e58 (patch) | |
| tree | 0ef2cb0e3048d13b82e4c7e81192df6124556a44 /django/db/backends/mysql/base.py | |
| parent | a3d96bee36040975ded8e3bf02e33e48d06f1f16 (diff) | |
Fixed #2443 -- Added DurationField.
A field for storing periods of time - modeled in Python by timedelta. It
is stored in the native interval data type on PostgreSQL and as a bigint
of microseconds on other backends.
Also includes significant changes to the internals of time related maths
in expressions, including the removal of DateModifierNode.
Thanks to Tim and Josh in particular for reviews.
Diffstat (limited to 'django/db/backends/mysql/base.py')
| -rw-r--r-- | django/db/backends/mysql/base.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py index 566ce6c0a7..8fcc9e0db1 100644 --- a/django/db/backends/mysql/base.py +++ b/django/db/backends/mysql/base.py @@ -289,9 +289,12 @@ class DatabaseOperations(BaseDatabaseOperations): sql = "CAST(DATE_FORMAT(%s, '%s') AS DATETIME)" % (field_name, format_str) return sql, params - def date_interval_sql(self, sql, connector, timedelta): - return "(%s %s INTERVAL '%d 0:0:%d:%d' DAY_MICROSECOND)" % (sql, connector, - timedelta.days, timedelta.seconds, timedelta.microseconds) + def date_interval_sql(self, timedelta): + return "INTERVAL '%d 0:0:%d:%d' DAY_MICROSECOND" % ( + timedelta.days, timedelta.seconds, timedelta.microseconds), [] + + def format_for_duration_arithmetic(self, sql): + return 'INTERVAL %s MICROSECOND' % sql def drop_foreignkey_sql(self): return "DROP FOREIGN KEY" |
