Skip to content

django: annotating DateTimeField + DurationField crashes #202

@timgraham

Description

@timgraham
======================================================================
ERROR: test_mixed_type_annotation_date_interval (annotations.tests.NonAggregateAnnotationTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/tim/code/django/tests/annotations/tests.py", line 137, in test_mixed_type_annotation_date_interval
    expires=ExpressionWrapper(F('active_at') + F('duration'), output_field=DateTimeField())
  File "/home/tim/code/django/django/db/models/query.py", line 653, in first
    for obj in (self if self.ordered else self.order_by('pk'))[:1]:
  File "/home/tim/code/django/django/db/models/query.py", line 274, in __iter__
    self._fetch_all()
  File "/home/tim/code/django/django/db/models/query.py", line 1242, in _fetch_all
    self._result_cache = list(self._iterable_class(self))
  File "/home/tim/code/django/django/db/models/query.py", line 55, in __iter__
    results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
  File "/home/tim/code/django/django/db/models/sql/compiler.py", line 1120, in execute_sql
    sql, params = self.as_sql()
  File "/home/tim/code/django/django/db/models/sql/compiler.py", line 474, in as_sql
    extra_select, order_by, group_by = self.pre_sql_setup()
  File "/home/tim/code/django/django/db/models/sql/compiler.py", line 54, in pre_sql_setup
    self.setup_query()
  File "/home/tim/code/django/django/db/models/sql/compiler.py", line 45, in setup_query
    self.select, self.klass_info, self.annotation_col_map = self.get_select()
  File "/home/tim/code/django/django/db/models/sql/compiler.py", line 254, in get_select
    sql, params = self.compile(col, select_format=True)
  File "/home/tim/code/django/django/db/models/sql/compiler.py", line 405, in compile
    sql, params = node.as_sql(self, self.connection)
  File "/home/tim/code/django/django/db/models/expressions.py", line 853, in as_sql
    return self.expression.as_sql(compiler, connection)
  File "/home/tim/code/django/django/db/models/expressions.py", line 428, in as_sql
    return DurationExpression(self.lhs, self.connector, self.rhs).as_sql(compiler, connection)
  File "/home/tim/code/django/django/db/models/expressions.py", line 474, in as_sql
    sql, params = self.compile(self.rhs, compiler, connection)
  File "/home/tim/code/django/django/db/models/expressions.py", line 464, in compile
    return connection.ops.format_for_duration_arithmetic(sql), params
AttributeError: 'DatabaseOperations' object has no attribute 'format_for_duration_arithmetic'

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions