File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed
Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -4969,15 +4969,20 @@ public function createOrUpdateDocumentsWithIncrease(
49694969 throw new AuthorizationException ($ validator ->getDescription ());
49704970 }
49714971
4972- $ createdAt = $ document ->getCreatedAt ();
49734972 $ updatedAt = $ document ->getUpdatedAt ();
49744973
49754974 $ document
49764975 ->setAttribute ('$id ' , empty ($ document ->getId ()) ? ID ::unique () : $ document ->getId ())
49774976 ->setAttribute ('$collection ' , $ collection ->getId ())
4978- ->setAttribute ('$createdAt ' , empty ($ createdAt ) || !$ this ->preserveDates ? $ time : $ createdAt )
49794977 ->setAttribute ('$updatedAt ' , empty ($ updatedAt ) || !$ this ->preserveDates ? $ time : $ updatedAt );
49804978
4979+ if ($ old ->isEmpty ()) {
4980+ $ createdAt = $ document ->getCreatedAt ();
4981+ $ document ->setAttribute ('$createdAt ' , empty ($ createdAt ) || !$ this ->preserveDates ? $ time : $ createdAt );
4982+ } else {
4983+ $ document ['$createdAt ' ] = $ old ->getCreatedAt ();
4984+ }
4985+
49814986 if (!$ updatesPermissions ) {
49824987 $ document ->setAttribute ('$permissions ' , $ old ->getPermissions ());
49834988 }
Original file line number Diff line number Diff line change @@ -368,7 +368,9 @@ public function testCreateOrUpdateDocuments(): void
368368
369369 $ this ->assertEquals (2 , $ count );
370370
371- foreach ($ results as $ document ) {
371+ $ createdAt = [];
372+ foreach ($ results as $ index => $ document ) {
373+ $ createdAt [$ index ] = $ document ->getCreatedAt ();
372374 $ this ->assertNotEmpty (true , $ document ->getId ());
373375 $ this ->assertIsString ($ document ->getAttribute ('string ' ));
374376 $ this ->assertEquals ('text📝 ' , $ document ->getAttribute ('string ' )); // Also makes sure an emoji is working
@@ -418,7 +420,8 @@ public function testCreateOrUpdateDocuments(): void
418420
419421 $ this ->assertEquals (2 , count ($ documents ));
420422
421- foreach ($ documents as $ document ) {
423+ foreach ($ documents as $ index => $ document ) {
424+ $ this ->assertEquals ($ createdAt [$ index ], $ document ->getCreatedAt ());
422425 $ this ->assertNotEmpty (true , $ document ->getId ());
423426 $ this ->assertIsString ($ document ->getAttribute ('string ' ));
424427 $ this ->assertEquals ('new text📝 ' , $ document ->getAttribute ('string ' )); // Also makes sure an emoji is working
You can’t perform that action at this time.
0 commit comments