From 611fcacd389318bea70eb97070aff13f6fcc1c79 Mon Sep 17 00:00:00 2001 From: n3vrax Date: Fri, 15 Sep 2017 12:52:32 +0300 Subject: [PATCH] array_filter data on save, can be overridden by force_nulls option flag --- CHANGELOG.md | 18 ++++++++++++++++++ src/Mapper/AbstractDbMapper.php | 5 +++++ 2 files changed, 23 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index edc24ba..6e82b83 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,21 @@ +## 0.4.3 - 2017-09-15 + +### Changed +* Nothing + +### Added +* array_filter on data before saving. Can be overridden with `force_nulls` option + +### Deprecated +* Nothing + +### Removed +* Nothing + +### Fixed +* Nothing + + ## 0.4.2 - 2017-05-12 ### Changed diff --git a/src/Mapper/AbstractDbMapper.php b/src/Mapper/AbstractDbMapper.php index 61e589c..4049d10 100644 --- a/src/Mapper/AbstractDbMapper.php +++ b/src/Mapper/AbstractDbMapper.php @@ -313,6 +313,11 @@ protected function processSave(EntityInterface $entity, array $options) return $event->last(); } + $forceNulls = (bool) $options['force_nulls'] ?? false; + if (!$forceNulls) { + $data = array_filter($data); + } + if ($isNew) { $success = $this->insert($entity, $data); } else {