Skip to content

Commit

Permalink
Removed the primary key in data when updating an entity.
Browse files Browse the repository at this point in the history
It fixes issue #3.
  • Loading branch information
Filipe Silva committed Oct 10, 2016
1 parent 4970216 commit 48eba20
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/Mapper/EntityMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,22 @@ protected function getData(Sql\SqlInterface $query)

return ($query instanceof Sql\Insert)
? $this->checkInsertData($data)
: $data;
: $this->checkUpdateData($data);
}

/**
* Clears the primary key for all update queries
*
* @param array $data
*
* @return mixed
*/
protected function checkUpdateData($data)
{
$primaryKey = $this->getDescriptor()->getPrimaryKey();
$name = $primaryKey->getName();
unset($data[$name]);
return $data;
}

/**
Expand Down

0 comments on commit 48eba20

Please sign in to comment.