summaryrefslogtreecommitdiff
path: root/django/db/models/sql/datastructures.py
diff options
context:
space:
mode:
Diffstat (limited to 'django/db/models/sql/datastructures.py')
-rw-r--r--django/db/models/sql/datastructures.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/django/db/models/sql/datastructures.py b/django/db/models/sql/datastructures.py
index b8e06daf01..612eb8f2d9 100644
--- a/django/db/models/sql/datastructures.py
+++ b/django/db/models/sql/datastructures.py
@@ -40,4 +40,25 @@ class Date(object):
col = '%s.%s' % tuple([qn(c) for c in self.col])
else:
col = self.col
- return connection.ops.date_trunc_sql(self.lookup_type, col)
+ return connection.ops.date_trunc_sql(self.lookup_type, col), []
+
+class DateTime(object):
+ """
+ Add a datetime selection column.
+ """
+ def __init__(self, col, lookup_type, tzname):
+ self.col = col
+ self.lookup_type = lookup_type
+ self.tzname = tzname
+
+ def relabel_aliases(self, change_map):
+ c = self.col
+ if isinstance(c, (list, tuple)):
+ self.col = (change_map.get(c[0], c[0]), c[1])
+
+ def as_sql(self, qn, connection):
+ if isinstance(self.col, (list, tuple)):
+ col = '%s.%s' % tuple([qn(c) for c in self.col])
+ else:
+ col = self.col
+ return connection.ops.datetime_trunc_sql(self.lookup_type, col, self.tzname)