From 1b1b1dfc2b8e3d9c99d832e949886088720cf8cf Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 1 Apr 2026 00:56:19 +1300 Subject: [PATCH] (fix): fix Metadata relatedCollection lookup, aggregate test aliases, and decorator silencing - Metadata decorator: look for relatedCollection inside options array since new Attribute format nests it there - Skip decorators during silenced operations to prevent $databaseId etc. from leaking into internal write operations - Fix aggregate test queries to use Query::count('*', 'total') instead of Query::count('total') which treats 'total' as a column name Co-Authored-By: Claude Opus 4.6 (1M context) --- composer.lock | 6 +++--- src/Appwrite/Utopia/Database/Hooks/Metadata.php | 4 +++- tests/e2e/Services/Databases/DatabasesBase.php | 12 ++++++------ 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/composer.lock b/composer.lock index c07cb1efaf..4d756d47ae 100644 --- a/composer.lock +++ b/composer.lock @@ -4038,12 +4038,12 @@ "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "93b7f4d01a2b7794374d53b7d5cf8e4b9d2509fe" + "reference": "84c0c749113178947a07bd047569dbe7f67f2906" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/93b7f4d01a2b7794374d53b7d5cf8e4b9d2509fe", - "reference": "93b7f4d01a2b7794374d53b7d5cf8e4b9d2509fe", + "url": "https://api.github.com/repos/utopia-php/database/zipball/84c0c749113178947a07bd047569dbe7f67f2906", + "reference": "84c0c749113178947a07bd047569dbe7f67f2906", "shasum": "" }, "require": { diff --git a/src/Appwrite/Utopia/Database/Hooks/Metadata.php b/src/Appwrite/Utopia/Database/Hooks/Metadata.php index 0b6f928dcb..24e8b94122 100644 --- a/src/Appwrite/Utopia/Database/Hooks/Metadata.php +++ b/src/Appwrite/Utopia/Database/Hooks/Metadata.php @@ -84,7 +84,9 @@ class Metadata implements Decorator } $relations = \is_array($related) ? $related : [$related]; - $relatedCollectionId = $relationship->getAttribute('relatedCollection'); + $options = $relationship->getAttribute('options', []); + $relatedCollectionId = (\is_array($options) ? ($options['relatedCollection'] ?? null) : null) + ?? $relationship->getAttribute('relatedCollection'); foreach ($relations as $relation) { if ($relation instanceof Document) { diff --git a/tests/e2e/Services/Databases/DatabasesBase.php b/tests/e2e/Services/Databases/DatabasesBase.php index 2d39bd84fd..74549be1dd 100644 --- a/tests/e2e/Services/Databases/DatabasesBase.php +++ b/tests/e2e/Services/Databases/DatabasesBase.php @@ -11402,7 +11402,7 @@ trait DatabasesBase 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ 'queries' => [ - Query::count('total')->toString(), + Query::count('*', 'total')->toString(), ], ]); @@ -11479,7 +11479,7 @@ trait DatabasesBase 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ 'queries' => [ - Query::count('total')->toString(), + Query::count('*', 'total')->toString(), Query::groupBy(['title'])->toString(), ], ]); @@ -11505,7 +11505,7 @@ trait DatabasesBase 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ 'queries' => [ - Query::count('total')->toString(), + Query::count('*', 'total')->toString(), Query::groupBy(['releaseYear'])->toString(), Query::having([Query::greaterThanEqual('total', 1)])->toString(), ], @@ -11601,7 +11601,7 @@ trait DatabasesBase 'x-appwrite-key' => $this->getProject()['apiKey'], ]), [ 'queries' => [ - Query::count('total')->toString(), + Query::count('*', 'total')->toString(), Query::join($libraryId, 'libraries', '$id')->toString(), Query::groupBy(['fullName'])->toString(), ], @@ -11648,7 +11648,7 @@ trait DatabasesBase ], $this->getHeaders()), [ 'queries' => [ Query::greaterThan('releaseYear', 2000)->toString(), - Query::count('total')->toString(), + Query::count('*', 'total')->toString(), ], ]); @@ -11874,7 +11874,7 @@ trait DatabasesBase ], [ 'queries' => [ Query::join($libraryId, 'library', '$id')->toString(), - Query::count('total')->toString(), + Query::count('*', 'total')->toString(), ], ]);