From 25ba0bb24d103925122a516014d3d76e81527467 Mon Sep 17 00:00:00 2001 From: Ingolf Steinhardt Date: Tue, 9 Jul 2019 22:27:05 +0200 Subject: [PATCH] Hotfix save empty string as null --- src/Attribute/Decimal.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Attribute/Decimal.php b/src/Attribute/Decimal.php index cb9dbba..381809f 100644 --- a/src/Attribute/Decimal.php +++ b/src/Attribute/Decimal.php @@ -125,6 +125,16 @@ public function searchFor($strPattern) return $query->fetchAll(\PDO::FETCH_COLUMN, 'id'); } + /** + * {@inheritDoc} + * + * This is needed for compatibility with MySQL strict mode so we will not write an empty string to decimal col. + */ + public function serializeData($value) + { + return $value === '' ? null : $value; + } + /** * Filter all values by specified operation. *