Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
timgraham opened this issue Nov 6, 2019 · 1 comment

Comments

@timgraham
Copy link
Collaborator

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>

@rafiss
Copy link
Contributor

rafiss commented Nov 13, 2019

CockroachDB issue: cockroachdb/cockroach#41943

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants