Opened 12 months ago

Closed 12 months ago

Last modified 12 months ago

#34941 closed Bug (fixed)

db_default with decimal.Decimal() doesn't return Decimal instances on Oracle.

Reported by: Mariusz Felisiak Owned by: Mariusz Felisiak
Component: Database layer (models, ORM) Version: 5.0
Severity: Release blocker Keywords: oracle db_default
Cc: David Sanders, Lily Foote Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Mariusz Felisiak)

While working on #34936 I noticed that DecimalField with db_default set to a Decimal() instance doesn't return Decimal() on Oracle:

/runtests.py field_defaults
Testing against Django installed in '/django/django' with up to 8 processes
Found 16 test(s).
Creating test database for alias 'default'...
Creating test user...
System check identified no issues (0 silenced).
.....s..sF......
======================================================================
FAIL: test_field_db_defaults_returning (field_defaults.tests.DefaultTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/django/django/test/testcases.py", line 1427, in skip_wrapper
    return test_func(*args, **kwargs)
  File "/django/tests/field_defaults/tests.py", line 48, in test_field_db_defaults_returning
    self.assertEqual(a.cost, Decimal("3.33"))
AssertionError: 3.33 != Decimal('3.33')

----------------------------------------------------------------------
Ran 16 tests in 0.089s

FAILED (failures=1, skipped=2)
Destroying test database for alias 'default'...
Destroying test user...
Destroying test database tables...

It works properly when using bulk_create().

Regression in 7414704e88d73dafbcfbb85f9bc54cb6111439d3.

Change History (9)

comment:1 by Mariusz Felisiak, 12 months ago

Description: modified (diff)

comment:2 by Natalia Bidart, 12 months ago

Triage Stage: UnreviewedAccepted

Thanks!

comment:3 by GitHub <noreply@…>, 12 months ago

In 7a09ba0:

Refs #34941 -- Skipped OperationTests.test_alter_field_change_nullable_to_decimal_database_default_not_null on Oracle.

comment:4 by Mariusz Felisiak <felisiak.mariusz@…>, 12 months ago

In e2330ccd:

[5.0.x] Refs #34941 -- Skipped OperationTests.test_alter_field_change_nullable_to_decimal_database_default_not_null on Oracle.

Backport of 7a09ba0962e0eaf4ad396475b392ba3234bf60ee from main

comment:5 by Mariusz Felisiak, 12 months ago

Description: modified (diff)

comment:6 by Mariusz Felisiak, 12 months ago

Owner: changed from nobody to Mariusz Felisiak
Status: newassigned

comment:7 by Mariusz Felisiak, 12 months ago

Has patch: set

comment:8 by GitHub <noreply@…>, 12 months ago

Resolution: fixed
Status: assignedclosed

In 656192c:

Fixed #34941 -- Fixed fetching decimal db_defaults for DecimalFields on Oracle.

This is a long standing bug in bc91f27a86090b4c688b56cd4e37f95eebe6e969
that began manifesting in 7414704e88d73dafbcfbb85f9bc54cb6111439d3.

comment:9 by Mariusz Felisiak <felisiak.mariusz@…>, 12 months ago

In 1383dc75:

[5.0.x] Fixed #34941 -- Fixed fetching decimal db_defaults for DecimalFields on Oracle.

This is a long standing bug in bc91f27a86090b4c688b56cd4e37f95eebe6e969
that began manifesting in 7414704e88d73dafbcfbb85f9bc54cb6111439d3.
Backport of 656192c2c96bb955a399d92f381e38fe2254fe17 from main

Note: See TracTickets for help on using tickets.
Back to Top