From d99a61ff28c2c4442802533dcaa8dc1fd638ff5f Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Wed, 24 Jun 2020 17:12:47 +0200 Subject: [PATCH] Fix updating decimal fields with default value (#3382) MySQL stores the default value using the specified number of decimals so that when comparing the existing default value with the new default value, the same format should be used. --- .../AbstractDecimalDatabaseTableColumn.class.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/wcfsetup/install/files/lib/system/database/table/column/AbstractDecimalDatabaseTableColumn.class.php b/wcfsetup/install/files/lib/system/database/table/column/AbstractDecimalDatabaseTableColumn.class.php index 5ba2b46a4b..6bf3ec6992 100644 --- a/wcfsetup/install/files/lib/system/database/table/column/AbstractDecimalDatabaseTableColumn.class.php +++ b/wcfsetup/install/files/lib/system/database/table/column/AbstractDecimalDatabaseTableColumn.class.php @@ -12,4 +12,16 @@ namespace wcf\system\database\table\column; */ abstract class AbstractDecimalDatabaseTableColumn extends AbstractDatabaseTableColumn implements IDecimalsDatabaseTableColumn { use TDecimalsDatabaseTableColumn; + + /** + * @inheritDoc + */ + public function getDefaultValue() { + $defaultValue = parent::getDefaultValue(); + if ($defaultValue === null) { + return $defaultValue; + } + + return number_format($defaultValue, $this->getDecimals() ?? 0, '.', ''); + } } -- 2.20.1