add postgres grains

This commit is contained in:
andrewhn 2016-04-05 13:56:10 +10:00 committed by Maxime Beauchemin
parent c7282882d5
commit 0d1f27dbc1
1 changed files with 8 additions and 0 deletions

View File

@ -337,6 +337,14 @@ class Database(Model, AuditMixinNullable):
Grain('week', 'DATE_SUB({col}, INTERVAL DAYOFWEEK({col}) - 1 DAY)'),
Grain('month', 'DATE_SUB({col}, INTERVAL DAYOFMONTH({col}) - 1 DAY)'),
),
'postgresql': (
Grain("Time Column", "{col}"),
Grain("hour", "DATE_TRUNC('hour', {col})"),
Grain("day", "DATE_TRUNC('day', {col})"),
Grain("week", "DATE_TRUNC('week', {col})"),
Grain("month", "DATE_TRUNC('month', {col})"),
Grain("year", "DATE_TRUNC('year', {col})"),
),
}
for db_type, grains in db_time_grains.items():
if self.sqlalchemy_uri.startswith(db_type):