cockroachdb / django-cockroachdb

CockroachDB Backend for Django

Home Page:http://cockroachlabs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unsupported query: sum(): unsupported binary operator: <float> + <int>

timgraham opened this issue · comments

Example query:

SELECT ... sum((("aggregation_book"."rating" + "aggregation_book"."pages") + "aggregation_book"."price")) AS "sums"
FROM "aggregation_book"
WHERE "aggregation_book"."id" = 501322346762469377
GROUP BY "aggregation_book"."id";

Where rating is FloatField and pages is IntegerField.

Django test failure:

======================================================================
ERROR: test_add_implementation (aggregation.tests.AggregateTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/tim/code/django/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
psycopg2.errors.InvalidParameterValue: sum(): unsupported binary operator: <float> + <int>


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/tim/code/django/tests/aggregation/tests.py", line 1045, in test_add_implementation
    b1 = qs.get(pk=self.b4.pk)
  File "/home/tim/code/django/django/db/models/query.py", line 402, in get
    num = len(clone)
  File "/home/tim/code/django/django/db/models/query.py", line 256, in __len__
    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 1100, in execute_sql
    cursor.execute(sql, params)
  File "/home/tim/code/django/django/db/backends/utils.py", line 99, in execute
    return super().execute(sql, params)
  File "/home/tim/code/django/django/db/backends/utils.py", line 67, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/home/tim/code/django/django/db/backends/utils.py", line 76, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/home/tim/code/django/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/home/tim/code/django/django/db/utils.py", line 89, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/home/tim/code/django/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
django.db.utils.DataError: sum(): unsupported binary operator: <float> + <int>