File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4920,7 +4920,7 @@ public function createOrUpdateDocumentsWithIncrease(
49204920 $ time = DateTime::now ();
49214921 $ created = 0 ;
49224922 $ updated = 0 ;
4923-
4923+ $ seenIds = [];
49244924 foreach ($ documents as $ key => $ document ) {
49254925 if ($ this ->getSharedTables () && $ this ->getTenantPerDocument ()) {
49264926 $ old = Authorization::skip (fn () => $ this ->withTenant ($ document ->getTenant (), fn () => $ this ->silent (fn () => $ this ->getDocument (
@@ -5028,12 +5028,19 @@ public function createOrUpdateDocumentsWithIncrease(
50285028 $ document = $ this ->silent (fn () => $ this ->createDocumentRelationships ($ collection , $ document ));
50295029 }
50305030
5031+ $ seenIds [] = $ document ->getId ();
5032+
50315033 $ documents [$ key ] = new Change (
50325034 old: $ old ,
50335035 new : $ document
50345036 );
50355037 }
50365038
5039+ // Required because *some* DBs will allow duplicate IDs for upsert
5040+ if (\count ($ seenIds ) !== \count (\array_unique ($ seenIds ))) {
5041+ throw new DuplicateException ('Duplicate document IDs found in the input array. ' );
5042+ }
5043+
50375044 foreach (\array_chunk ($ documents , $ batchSize ) as $ chunk ) {
50385045 /**
50395046 * @var array<Change> $chunk
You can’t perform that action at this time.
0 commit comments