Skip to content

Unsupported query: UPDATE float column with integer column #20

@timgraham

Description

@timgraham

For example:

======================================================================
ERROR: test_increment_value (expressions.tests.ExpressionsNumericTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/tim/code/django/django/test/testcases.py", line 267, in __call__
    self._pre_setup()
  File "/home/tim/code/django/django/test/testcases.py", line 938, in _pre_setup
    self._fixture_setup()
  File "/home/tim/code/django/django/test/testcases.py", line 1165, in _fixture_setup
    self.setUpTestData()
  File "/home/tim/code/django/tests/expressions/tests.py", line 893, in setUpTestData
    Number.objects.update(float=F('integer'))
  File "/home/tim/code/django/django/db/models/manager.py", line 82, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/home/tim/code/django/django/db/models/query.py", line 741, in update
    rows = query.get_compiler(self.db).execute_sql(CURSOR)
  File "/home/tim/code/django/django/db/models/sql/compiler.py", line 1429, in execute_sql
    cursor = super().execute_sql(result_type)
  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 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.ProgrammingError: value type int doesn't match type FLOAT8 of column "the_float"

Is there a plan to add support?

The SQL assigns values from an integer column to a float column:

UPDATE "expressions_number" SET "the_float" = "expressions_number"."the_integer";

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions