@@ -996,7 +996,7 @@ function () use ($initData, $data, $item, $options, $condFields, $conditions) {
996996
997997 public function upsert (
998998 array |object $ item ,
999- ? array $ condFields = null ,
999+ array | string | null $ condFields = null ,
10001000 ORMOptions $ options = new ORMOptions ()
10011001 ): ?StatementInterface {
10021002 if ($ item === []) {
@@ -1005,12 +1005,11 @@ public function upsert(
10051005
10061006 $ metadata = $ this ->getMetadata ();
10071007
1008- $ updateNulls = true ;
1008+ $ updateNulls = $ options -> updateNulls ;
10091009
1010- // $updateNulls = $options->updateNulls;
1011- // if ($this->metadata::isEntity($item)) {
1012- // $updateNulls = true;
1013- // }
1010+ if ($ this ->metadata ::isEntity ($ item )) {
1011+ $ updateNulls = true ;
1012+ }
10141013
10151014 if (!$ condFields ) {
10161015 $ condFields = $ this ->getKeys ();
@@ -1044,6 +1043,9 @@ public function upsert(
10441043 $ metadata ->getTableName (),
10451044 $ data ,
10461045 $ condFields ,
1046+ [
1047+ 'updateNulls ' => $ updateNulls ,
1048+ ]
10471049 );
10481050 }
10491051
@@ -1740,7 +1742,12 @@ public function toEntity(array|object $data): object
17401742 }
17411743
17421744 if (is_object ($ data )) {
1743- $ data = ReflectAccessor::getPropertiesValues ($ data );
1745+ if (EntityMetadata::isEntity ($ data )) {
1746+ // Keep B/C that we must extract protected props from old entities.
1747+ $ data = ReflectAccessor::getPropertiesValues ($ data );
1748+ } else {
1749+ $ data = TypeCast::toArray ($ data );
1750+ }
17441751 }
17451752
17461753 // Only ORM has Hydrator, we must call ORM to do this.
0 commit comments