Skip to content

Commit 0e48bd0

Browse files
committed
Only update data when necessary
1 parent 64f14bc commit 0e48bd0

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/LightQL/Entities/Entity.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,12 @@ abstract class Entity implements IEntity
7474
private $_reflection = null;
7575

7676
/**
77-
* The array of database column of this entity.
77+
* The array of database columns of this entity.
7878
*
7979
* @var Column[]
8080
*/
8181
private $_columns = array();
8282

83-
8483
/**
8584
* Entity constructor.
8685
*
@@ -133,7 +132,7 @@ public function hydrate(array $data)
133132
foreach ($this->_columns as $property => $column) {
134133
if (array_key_exists($column->getName(), $this->raw)) {
135134
$this->{$property} = $this->raw[$column->getName()];
136-
} else {
135+
} elseif (\is_null($this->{$property}) || $this->{$property} === null) {
137136
$this->{$property} = $column->getDefault();
138137
}
139138
}

0 commit comments

Comments
 (0)