From b0b30247204aea8096b3c5456d71c2df9bc4f4ae Mon Sep 17 00:00:00 2001 From: Simon Charette Date: Sat, 7 Dec 2024 10:07:55 -0500 Subject: [PATCH] Refs #35982 -- Made BaseDatabaseOperations.adapt_decimalfield_value() a no-op. --- django/db/backends/base/operations.py | 3 +-- django/db/backends/mysql/operations.py | 3 --- django/db/backends/oracle/operations.py | 3 --- django/db/backends/postgresql/operations.py | 3 --- docs/releases/5.2.txt | 2 ++ 5 files changed, 3 insertions(+), 11 deletions(-) diff --git a/django/db/backends/base/operations.py b/django/db/backends/base/operations.py index dba9fcbba8..60de2d6c79 100644 --- a/django/db/backends/base/operations.py +++ b/django/db/backends/base/operations.py @@ -8,7 +8,6 @@ import sqlparse from django.conf import settings from django.db import NotSupportedError, transaction -from django.db.backends import utils from django.db.models.expressions import Col from django.utils import timezone from django.utils.deprecation import RemovedInDjango60Warning @@ -586,7 +585,7 @@ class BaseDatabaseOperations: Transform a decimal.Decimal value to an object compatible with what is expected by the backend driver for decimal (numeric) columns. """ - return utils.format_number(value, max_digits, decimal_places) + return value def adapt_ipaddressfield_value(self, value): """ diff --git a/django/db/backends/mysql/operations.py b/django/db/backends/mysql/operations.py index 9741e6a985..9806303539 100644 --- a/django/db/backends/mysql/operations.py +++ b/django/db/backends/mysql/operations.py @@ -166,9 +166,6 @@ class DatabaseOperations(BaseDatabaseOperations): """ return [(None, ("NULL", [], False))] - def adapt_decimalfield_value(self, value, max_digits=None, decimal_places=None): - return value - def last_executed_query(self, cursor, sql, params): # With MySQLdb, cursor objects have an (undocumented) "_executed" # attribute where the exact query sent to the database is saved. diff --git a/django/db/backends/oracle/operations.py b/django/db/backends/oracle/operations.py index 86340bbf4a..79c6da994e 100644 --- a/django/db/backends/oracle/operations.py +++ b/django/db/backends/oracle/operations.py @@ -629,9 +629,6 @@ END; 1900, 1, 1, value.hour, value.minute, value.second, value.microsecond ) - def adapt_decimalfield_value(self, value, max_digits=None, decimal_places=None): - return value - def combine_expression(self, connector, sub_expressions): lhs, rhs = sub_expressions if connector == "%%": diff --git a/django/db/backends/postgresql/operations.py b/django/db/backends/postgresql/operations.py index d89f81bf7e..8a0ca36a29 100644 --- a/django/db/backends/postgresql/operations.py +++ b/django/db/backends/postgresql/operations.py @@ -346,9 +346,6 @@ class DatabaseOperations(BaseDatabaseOperations): def adapt_timefield_value(self, value): return value - def adapt_decimalfield_value(self, value, max_digits=None, decimal_places=None): - return value - def adapt_ipaddressfield_value(self, value): if value: return Inet(value) diff --git a/docs/releases/5.2.txt b/docs/releases/5.2.txt index b6c44c43f8..907159e36d 100644 --- a/docs/releases/5.2.txt +++ b/docs/releases/5.2.txt @@ -399,6 +399,8 @@ backends. * The new :meth:`Model._is_pk_set() ` method allows checking if a Model instance's primary key is defined. +* ``BaseDatabaseOperations.adapt_decimalfield_value()`` is now a no-op, simply + returning the given value. :mod:`django.contrib.gis` -------------------------