From 7eba6582c6128040cb1a5674ec4f09c486610790 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 4 Sep 2025 20:32:37 +1200 Subject: [PATCH] Fix bulk payloads --- .../Databases/Http/Transactions/Update.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Transactions/Update.php b/src/Appwrite/Platform/Modules/Databases/Http/Transactions/Update.php index 9d4eae41c9..b8b77d79ef 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Transactions/Update.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Transactions/Update.php @@ -223,10 +223,9 @@ class Update extends Action case 'bulkCreate': $dbForProject->createDocuments( $collectionId, - array_map(fn ($data) => new Document($data), $data), + $data, onNext: function (Document $document) use (&$state, $collectionId) { $state[$collectionId][$document->getId()] = $document; - } ); break; @@ -234,7 +233,7 @@ class Update extends Action case 'bulkUpdate': $dbForProject->updateDocuments( $collectionId, - $data['data'] ?? null, + new Document($data['data']), Query::parseQueries($data['queries'] ?? []) ); break; @@ -242,10 +241,9 @@ class Update extends Action case 'bulkUpsert': $dbForProject->createOrUpdateDocuments( $collectionId, - array_map(fn ($data) => new Document($data), $data), + $data, onNext: function (Document $document) use (&$state, $collectionId) { $state[$collectionId][$document->getId()] = $document; - } ); break; @@ -272,16 +270,16 @@ class Update extends Action ->setType(DELETE_TYPE_DOCUMENT) ->setDocument($transaction); - } catch (NotFoundException) { + } catch (NotFoundException $e) { $dbForProject->updateDocument('transactions', $transactionId, new Document([ 'status' => 'failed', ])); - throw new Exception(Exception::DOCUMENT_NOT_FOUND); - } catch (DuplicateException|ConflictException) { + throw new Exception(Exception::DOCUMENT_NOT_FOUND, previous: $e); + } catch (DuplicateException|ConflictException $e) { $dbForProject->updateDocument('transactions', $transactionId, new Document([ 'status' => 'failed', ])); - throw new Exception(Exception::TRANSACTION_CONFLICT); + throw new Exception(Exception::TRANSACTION_CONFLICT, previous: $e); } catch (TransactionException $e) { $dbForProject->updateDocument('transactions', $transactionId, new Document([ 'status' => 'failed',