Db2 Grain Correct Data Format (#2545)

* Db2 Grain Correct Data Format

* Db2 Grain Correct Data Format.

* Db2 Grain Correct Data Format + typo

* Db2 Grain Correct Data Format +typo
This commit is contained in:
openmax 2017-04-05 09:03:24 +02:00 committed by Maxime Beauchemin
parent fe68bc31c3
commit 62959ca38b

View File

@ -195,14 +195,35 @@ class Db2EngineSpec(BaseEngineSpec):
engine = 'ibm_db_sa' engine = 'ibm_db_sa'
time_grains = ( time_grains = (
Grain('Time Column', _('Time Column'), '{col}'), Grain('Time Column', _('Time Column'), '{col}'),
Grain('second', _('second'), 'SECOND({col})'), Grain('second', _('second'),
Grain('minute', _('minute'), 'MINUTE({col})'), 'CAST({col} as TIMESTAMP)'
Grain('hour', _('hour'), 'HOUR({col})'), ' - MICROSECOND({col}) MICROSECONDS'),
Grain('day', _('day'), 'DAY({col})'), Grain('minute', _('minute'),
Grain('week', _('week'), 'WEEK({col})'), 'CAST({col} as TIMESTAMP)'
Grain('month', _('month'), 'MONTH({col})'), ' - SECOND({col}) SECONDS'
Grain('quarter', _('quarter'), 'QUARTER({col})'), ' - MICROSECOND({col}) MICROSECONDS'),
Grain('year', _('year'), 'YEAR({col})'), Grain('hour', _('hour'),
'CAST({col} as TIMESTAMP)'
' - MINUTE({col}) MINUTES'
' - SECOND({col}) SECONDS'
' - MICROSECOND({col}) MICROSECONDS '),
Grain('day', _('day'),
'CAST({col} as TIMESTAMP)'
' - HOUR({col}) HOURS'
' - MINUTE({col}) MINUTES'
' - SECOND({col}) SECONDS'
' - MICROSECOND({col}) MICROSECONDS '),
Grain('week', _('week'),
'{col} - (DAYOFWEEK({col})) DAYS'),
Grain('month', _('month'),
'{col} - (DAY({col})-1) DAYS'),
Grain('quarter', _('quarter'),
'{col} - (DAY({col})-1) DAYS'
' - (MONTH({col})-1) MONTHS'
' + ((QUARTER({col})-1) * 3) MONTHS'),
Grain('year', _('year'),
'{col} - (DAY({col})-1) DAYS'
' - (MONTH({col})-1) MONTHS'),
) )
@classmethod @classmethod