From 473be9284d8c3fb0767fd0df8ced1681a12906bd Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 2 Oct 2025 22:24:54 +1300 Subject: [PATCH] Check convert --- .../Http/Databases/Transactions/Update.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Transactions/Update.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Transactions/Update.php index ac2efc31cf..afa466c366 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Transactions/Update.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Transactions/Update.php @@ -544,9 +544,14 @@ class Update extends Action array &$state ): void { $dbForProject->withRequestTimestamp($createdAt, function () use ($dbForProject, $collectionId, $data, &$state) { + // Convert data arrays to Document objects if needed + $documents = \array_map(function ($doc) { + return $doc instanceof Document ? $doc : new Document($doc); + }, $data); + $dbForProject->createDocuments( $collectionId, - \array_map(fn($doc) => new Document($doc), $data), + $documents, onNext: function (Document $document) use (&$state, $collectionId) { $state[$collectionId][$document->getId()] = $document; } @@ -601,10 +606,15 @@ class Update extends Action \DateTime $createdAt, array &$state ): void { + // Convert data arrays to Document objects if needed + $documents = \array_map(function ($doc) { + return $doc instanceof Document ? $doc : new Document($doc); + }, $data); + // Run bulk upsert without timestamp wrapper, checking manually in callback $dbForProject->upsertDocuments( $collectionId, - \array_map(fn($doc) => new Document($doc), $data), + $documents, onNext: function (Document $upserted, ?Document $old) use (&$state, $collectionId, $createdAt) { if ($old !== null) { // This is an update - check if document was created/modified in this transaction