File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -4916,8 +4916,8 @@ public function createOrUpdateDocumentsWithIncrease(
49164916 $ batchSize = \min (Database::INSERT_BATCH_SIZE , \max (1 , $ batchSize ));
49174917 $ collection = $ this ->silent (fn () => $ this ->getCollection ($ collection ));
49184918 $ documentSecurity = $ collection ->getAttribute ('documentSecurity ' , false );
4919+ $ collectionAttributes = $ collection ->getAttribute ('attributes ' , []);
49194920 $ time = DateTime::now ();
4920-
49214921 $ created = 0 ;
49224922 $ updated = 0 ;
49234923
@@ -4980,6 +4980,14 @@ public function createOrUpdateDocumentsWithIncrease(
49804980 if ($ old ->isEmpty ()) {
49814981 $ createdAt = $ document ->getCreatedAt ();
49824982 $ document ->setAttribute ('$createdAt ' , empty ($ createdAt ) || !$ this ->preserveDates ? $ time : $ createdAt );
4983+
4984+ // Force matching optional parameter sets
4985+ // Doesn't use decode as that intentionally skips null defaults to reduce payload size
4986+ foreach ($ collectionAttributes as $ attr ) {
4987+ if (!$ attr ->getAttribute ('required ' ) && !$ document ->isSet ($ attr ['$id ' ])) {
4988+ $ document ->setAttribute ($ attr ['$id ' ], $ attr ['default ' ] ?? null );
4989+ }
4990+ }
49834991 } else {
49844992 $ document ['$createdAt ' ] = $ old ->getCreatedAt ();
49854993 }
You can’t perform that action at this time.
0 commit comments