From 77c69ce793be77ea5cab187585801579824b184e Mon Sep 17 00:00:00 2001 From: fogelito Date: Wed, 11 Feb 2026 15:20:47 +0200 Subject: [PATCH] add tests --- composer.lock | 20 ++++++------- .../Databases/Collections/Documents/XList.php | 1 + .../TablesDB/DatabasesConsoleClientTest.php | 28 +++++++++++++++++-- 3 files changed, 36 insertions(+), 13 deletions(-) diff --git a/composer.lock b/composer.lock index 59fd3415cf..146780f966 100644 --- a/composer.lock +++ b/composer.lock @@ -3799,12 +3799,12 @@ "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "eb863401e90b4fcf84ca02c92675db3c30b331a3" + "reference": "ba6763fad1e9be986c0e31ffe344a65298b62468" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/eb863401e90b4fcf84ca02c92675db3c30b331a3", - "reference": "eb863401e90b4fcf84ca02c92675db3c30b331a3", + "url": "https://api.github.com/repos/utopia-php/database/zipball/ba6763fad1e9be986c0e31ffe344a65298b62468", + "reference": "ba6763fad1e9be986c0e31ffe344a65298b62468", "shasum": "" }, "require": { @@ -3849,7 +3849,7 @@ "issues": "https://github.com/utopia-php/database/issues", "source": "https://github.com/utopia-php/database/tree/joins8" }, - "time": "2026-02-11T08:31:25+00:00" + "time": "2026-02-11T13:08:54+00:00" }, { "name": "utopia-php/detector", @@ -5488,16 +5488,16 @@ "packages-dev": [ { "name": "appwrite/sdk-generator", - "version": "1.8.27", + "version": "1.8.28", "source": { "type": "git", "url": "https://github.com/appwrite/sdk-generator.git", - "reference": "9c6927336a163954c0ed6d8208af8d5b83761762" + "reference": "4762aa017b28a3a7e4e53da6e193d0c196ec3fd4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/9c6927336a163954c0ed6d8208af8d5b83761762", - "reference": "9c6927336a163954c0ed6d8208af8d5b83761762", + "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/4762aa017b28a3a7e4e53da6e193d0c196ec3fd4", + "reference": "4762aa017b28a3a7e4e53da6e193d0c196ec3fd4", "shasum": "" }, "require": { @@ -5533,9 +5533,9 @@ "description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms", "support": { "issues": "https://github.com/appwrite/sdk-generator/issues", - "source": "https://github.com/appwrite/sdk-generator/tree/1.8.27" + "source": "https://github.com/appwrite/sdk-generator/tree/1.8.28" }, - "time": "2026-02-10T06:10:29+00:00" + "time": "2026-02-11T10:35:18+00:00" }, { "name": "doctrine/annotations", diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/XList.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/XList.php index 5ff3619c2f..08c4b04ba3 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/XList.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/XList.php @@ -146,6 +146,7 @@ class XList extends Action // has selects, allow relationship on documents $documents = $dbForProject->find($collectionTableId, $queries); $total = $includeTotal ? $dbForProject->count($collectionTableId, $queries, APP_LIMIT_COUNT) : 0; + var_dump($documents); } else { // has no selects, disable relationship loading on documents /* @type Document[] $documents */ diff --git a/tests/e2e/Services/Databases/TablesDB/DatabasesConsoleClientTest.php b/tests/e2e/Services/Databases/TablesDB/DatabasesConsoleClientTest.php index 8335c0a621..0f3143747b 100644 --- a/tests/e2e/Services/Databases/TablesDB/DatabasesConsoleClientTest.php +++ b/tests/e2e/Services/Databases/TablesDB/DatabasesConsoleClientTest.php @@ -183,7 +183,9 @@ class DatabasesConsoleClientTest extends Scope 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ 'queries' => [ - Query::join($sessions['body']['$id'], 'B', [Query::relationEqual('', '$sequence','B', 'userId')])->toString(), + Query::join($sessions['body']['$id'], 'B', [ + Query::relationEqual('', '$sequence','B', 'userId') + ])->toString(), Query::orderDesc('username', '')->toString(), ], ]); @@ -209,12 +211,13 @@ class DatabasesConsoleClientTest extends Scope 'queries' => [ Query::select('username', '')->toString(), Query::select('userId', 'B')->toString(), - Query::join($sessions['body']['$id'], 'B', [Query::relationEqual('', '$sequence','B', 'userId')])->toString(), + Query::join($sessions['body']['$id'], 'B', [ + Query::relationEqual('', '$sequence','B', 'userId') + ])->toString(), Query::orderDesc('username', '')->toString(), ], ]); - var_dump($rows); $this->assertEquals(2, $rows['body']['total']); $this->assertEquals('Bill', $rows['body']['rows'][0]['username']); $this->assertEquals('Abraham', $rows['body']['rows'][1]['username']); @@ -227,6 +230,25 @@ class DatabasesConsoleClientTest extends Scope $this->assertArrayNotHasKey('$updatedAt', $rows['body']['rows'][0]); $this->assertArrayNotHasKey('$permissions', $rows['body']['rows'][0]); + /** + * Simple join query + equal query + */ + $rows = $this->client->call(Client::METHOD_GET, '/tablesdb/' . $databaseId . '/tables/' . $users['body']['$id'] . '/rows', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'queries' => [ + Query::select('*', 'B')->toString(), + Query::equal('userId', [$bill['body']['$sequence']], 'B')->toString(), + Query::join($sessions['body']['$id'], 'B', [ + Query::relationEqual('', '$sequence','B', 'userId') + ])->toString(), + ], + ]); + + $this->assertEquals(1, $rows['body']['total']); + $this->assertEquals($bill['body']['$sequence'], $rows['body']['rows'][0]['userId']); + $this->assertArrayNotHasKey('username', $rows['body']['rows'][0]); $this->assertEquals('shmuel', 'fogel'); }