Skip to content

Commit

Permalink
array_filter data on save, can be overridden by force_nulls option flag
Browse files Browse the repository at this point in the history
  • Loading branch information
n3vrax authored and n3vrax committed Sep 15, 2017
1 parent 2addbcd commit 611fcac
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/Mapper/AbstractDbMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 611fcac

Please sign in to comment.