Skip to content

Commit

Permalink
Merge pull request #251 from bancer/patch-3
Browse files Browse the repository at this point in the history
BitmaskedBehavior - do not set mapped field if it is not present in SELECT
  • Loading branch information
dereuromark committed Dec 23, 2019
2 parents 05739ab + 5019a4b commit 52322c8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Model/Behavior/BitmaskedBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,10 @@ public function beforeFind(Event $event, Query $query, ArrayObject $options, $pr

/** @var \Cake\Datasource\EntityInterface $entity */
$entity = $row;
$entity->set($mappedField, $this->decodeBitmask($entity->get($field)));
$entity->setDirty($mappedField, false);
if ($entity->has($field)) {
$entity->set($mappedField, $this->decodeBitmask($entity->get($field)));
$entity->setDirty($mappedField, false);
}
$mr->emit($entity);
};
$query->mapReduce($mapper);
Expand Down

0 comments on commit 52322c8

Please sign in to comment.