diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Attribute/Decrement.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Attribute/Decrement.php index a3a1ea6ce8..53831f0fc5 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Attribute/Decrement.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Attribute/Decrement.php @@ -177,6 +177,7 @@ class Decrement extends Action value: $value, min: $min ); + $document->setAttribute('$databaseId', $database->getId()); $document->setAttribute('$' . $this->getCollectionsEventsContext() . 'Id', $collectionId); } catch (ConflictException) { throw new Exception($this->getConflictException()); diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Attribute/Increment.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Attribute/Increment.php index 157c5ef2af..ea680db3b1 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Attribute/Increment.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Attribute/Increment.php @@ -177,6 +177,7 @@ class Increment extends Action value: $value, max: $max ); + $document->setAttribute('$databaseId', $database->getId()); $document->setAttribute('$' . $this->getCollectionsEventsContext() . 'Id', $collectionId); } catch (ConflictException) { throw new Exception($this->getConflictException()); diff --git a/tests/e2e/Services/Databases/Legacy/DatabasesBase.php b/tests/e2e/Services/Databases/Legacy/DatabasesBase.php index d1d2c9687d..6cde01e240 100644 --- a/tests/e2e/Services/Databases/Legacy/DatabasesBase.php +++ b/tests/e2e/Services/Databases/Legacy/DatabasesBase.php @@ -6119,6 +6119,7 @@ trait DatabasesBase $this->assertEquals(200, $inc['headers']['status-code']); $this->assertEquals(6, $inc['body']['count']); $this->assertEquals($collectionId, $inc['body']['$collectionId']); + $this->assertEquals($databaseId, $inc['body']['$databaseId']); // Verify count = 6 $get = $this->client->call(Client::METHOD_GET, "/databases/$databaseId/collections/$collectionId/documents/$docId", array_merge([ @@ -6231,6 +6232,7 @@ trait DatabasesBase $this->assertEquals(200, $dec['headers']['status-code']); $this->assertEquals(9, $dec['body']['count']); $this->assertEquals($collectionId, $dec['body']['$collectionId']); + $this->assertEquals($databaseId, $dec['body']['$databaseId']); $get = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/collections/' . $collectionId . '/documents/' . $documentId, array_merge([ 'content-type' => 'application/json', diff --git a/tests/e2e/Services/Databases/Legacy/Transactions/TransactionsBase.php b/tests/e2e/Services/Databases/Legacy/Transactions/TransactionsBase.php index 0f85de0ff5..d4acfc338c 100644 --- a/tests/e2e/Services/Databases/Legacy/Transactions/TransactionsBase.php +++ b/tests/e2e/Services/Databases/Legacy/Transactions/TransactionsBase.php @@ -3827,6 +3827,7 @@ trait TransactionsBase $this->assertArrayHasKey('$collectionId', $decrementResponse['body'], 'Response should contain $collectionId for Collections API'); $this->assertArrayNotHasKey('$tableId', $decrementResponse['body'], 'Response should not contain $tableId for Collections API'); $this->assertEquals($collectionId, $decrementResponse['body']['$collectionId']); + $this->assertEquals($databaseId, $decrementResponse['body']['$databaseId']); // Test increment endpoint $incrementResponse = $this->client->call( @@ -3846,6 +3847,7 @@ trait TransactionsBase $this->assertArrayHasKey('$collectionId', $incrementResponse['body'], 'Response should contain $collectionId for Collections API'); $this->assertArrayNotHasKey('$tableId', $incrementResponse['body'], 'Response should not contain $tableId for Collections API'); $this->assertEquals($collectionId, $incrementResponse['body']['$collectionId']); + $this->assertEquals($databaseId, $incrementResponse['body']['$databaseId']); // Commit transaction - this will fail if transaction log has 'column' instead of 'attribute' $commitResponse = $this->client->call(Client::METHOD_PATCH, "/databases/transactions/{$transactionId}", array_merge([ diff --git a/tests/e2e/Services/Databases/TablesDB/DatabasesBase.php b/tests/e2e/Services/Databases/TablesDB/DatabasesBase.php index ba111e5923..bcb87e92d5 100644 --- a/tests/e2e/Services/Databases/TablesDB/DatabasesBase.php +++ b/tests/e2e/Services/Databases/TablesDB/DatabasesBase.php @@ -7761,6 +7761,7 @@ trait DatabasesBase ])); $this->assertEquals(200, $inc['headers']['status-code']); $this->assertEquals($tableId, $inc['body']['$tableId']); + $this->assertEquals($databaseId, $inc['body']['$databaseId']); $this->assertEquals(6, $inc['body']['count']); // Verify count = 6 @@ -7874,6 +7875,7 @@ trait DatabasesBase $this->assertEquals(200, $dec['headers']['status-code']); $this->assertEquals(9, $dec['body']['count']); $this->assertEquals($tableId, $dec['body']['$tableId']); + $this->assertEquals($databaseId, $dec['body']['$databaseId']); $get = $this->client->call(Client::METHOD_GET, '/tablesdb/' . $databaseId . '/tables/' . $tableId . '/rows/' . $rowId, array_merge([ 'content-type' => 'application/json', diff --git a/tests/e2e/Services/Databases/TablesDB/Transactions/TransactionsBase.php b/tests/e2e/Services/Databases/TablesDB/Transactions/TransactionsBase.php index 488dc60239..a5af7053f0 100644 --- a/tests/e2e/Services/Databases/TablesDB/Transactions/TransactionsBase.php +++ b/tests/e2e/Services/Databases/TablesDB/Transactions/TransactionsBase.php @@ -3963,6 +3963,7 @@ trait TransactionsBase $this->assertArrayHasKey('$tableId', $decrementResponse['body'], 'Response should contain $tableId for TablesDB API'); $this->assertArrayNotHasKey('$collectionId', $decrementResponse['body'], 'Response should not contain $collectionId for TablesDB API'); $this->assertEquals($tableId, $decrementResponse['body']['$tableId']); + $this->assertEquals($databaseId, $decrementResponse['body']['$databaseId']); // Test increment endpoint $incrementResponse = $this->client->call( @@ -3982,6 +3983,7 @@ trait TransactionsBase $this->assertArrayHasKey('$tableId', $incrementResponse['body'], 'Response should contain $tableId for TablesDB API'); $this->assertArrayNotHasKey('$collectionId', $incrementResponse['body'], 'Response should not contain $collectionId for TablesDB API'); $this->assertEquals($tableId, $incrementResponse['body']['$tableId']); + $this->assertEquals($databaseId, $incrementResponse['body']['$databaseId']); // Commit transaction - this will fail if transaction log has 'attribute' instead of 'column' $commitResponse = $this->client->call(Client::METHOD_PATCH, "/tablesdb/transactions/{$transactionId}", array_merge([