jamessewell / django-timescaledb

A Django database backend and tooling for Timescaledb.
Apache License 2.0
185 stars 47 forks source link

chore: fixed "You must set output_field" bug #21

Closed duml closed 3 years ago

duml commented 3 years ago

Metric.timescale.filter(timerange=ranges).time_bucket('time', '1 hour') Traceback (most recent call last): File "/usr/lib/python3.6/code.py", line 91, in runcode exec(code, self.locals) File "", line 1, in File "/data/venv/lib/python3.6/site-packages/django/db/models/query.py", line 256, in repr data = list(self[:REPR_OUTPUT_SIZE + 1]) File "/data/venv/lib/python3.6/site-packages/django/db/models/query.py", line 280, in iter self._fetch_all() File "/data/venv/lib/python3.6/site-packages/django/db/models/query.py", line 1324, in _fetch_all self._result_cache = list(self._iterable_class(self)) File "/data/venv/lib/python3.6/site-packages/django/db/models/query.py", line 109, in iter for row in compiler.results_iter(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size): File "/data/venv/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 1130, in results_iter results = self.execute_sql(MULTI, chunked_fetch=chunked_fetch, chunk_size=chunk_size) File "/data/venv/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 1162, in execute_sql sql, params = self.as_sql() File "/data/venv/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 513, in as_sql extra_select, order_by, group_by = self.pre_sql_setup() File "/data/venv/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 55, in pre_sql_setup self.setup_query() File "/data/venv/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 46, in setup_query self.select, self.klass_info, self.annotation_col_map = self.get_select() File "/data/venv/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 267, in get_select sql, params = col.select_format(self, sql, params) File "/data/venv/lib/python3.6/site-packages/django/db/models/expressions.py", line 390, in select_format print(self.output_field) File "/data/venv/lib/python3.6/site-packages/django/utils/functional.py", line 48, in get res = instance.dict[self.name] = self.func(instance) File "/data/venv/lib/python3.6/site-packages/django/db/models/expressions.py", line 265, in output_field output_field = self._resolve_output_field() File "/data/venv/lib/python3.6/site-packages/django/db/models/expressions.py", line 306, in _resolve_output_field source.class.name__, django.core.exceptions.FieldError: Expression contains mixed types: CharField, TimescaleDateTimeField. You must set output_field.

schlunsen commented 3 years ago

@duml Thanks!