Skip to content

Commit

Permalink
Merge pull request #4071 from najdanovicivan/nosql/base-model-fix
Browse files Browse the repository at this point in the history
Model/BaseModel - Fix primary key and  add @throws for builder method
  • Loading branch information
paulbalandan authored Jan 7, 2021
2 parents c5adf56 + b01cb98 commit e67d29f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 7 deletions.
7 changes: 0 additions & 7 deletions system/BaseModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -1675,13 +1675,6 @@ protected function objectToRawArray($data, bool $onlyChanged = true, bool $recur
if (method_exists($data, 'toRawArray'))
{
$properties = $data->toRawArray($onlyChanged, $recursive);

// Always grab the primary key otherwise updates will fail.
if (! empty($properties) && ! empty($this->primaryKey) && ! in_array($this->primaryKey, $properties, true)
&& ! empty($data->{$this->primaryKey}))
{
$properties[$this->primaryKey] = $data->{$this->primaryKey};
}
}
else
{
Expand Down
1 change: 1 addition & 0 deletions system/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,7 @@ public function countAllResults(bool $reset = true, bool $test = false)
* @param string|null $table Table name
*
* @return BaseBuilder
* @throws ModelException
*/
public function builder(?string $table = null)
{
Expand Down

0 comments on commit e67d29f

Please sign in to comment.