From 33f7081c1825122073b50498fa91bf959ab45a3d Mon Sep 17 00:00:00 2001 From: fogelito Date: Wed, 30 Jul 2025 14:02:12 +0300 Subject: [PATCH 01/13] Reproduce --- src/Database/Database.php | 11 +- tests/e2e/Adapter/Base.php | 10 +- .../e2e/Adapter/Scopes/RelationshipTests.php | 209 ++++++++++++++++++ 3 files changed, 221 insertions(+), 9 deletions(-) diff --git a/src/Database/Database.php b/src/Database/Database.php index cc1336625..38ff70c29 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -3283,7 +3283,7 @@ public function getDocument(string $collection, string $id, array $queries = [], $document = $this->decode($collection, $document, $selections); $this->map = []; - if ($this->resolveRelationships && (empty($selects) || !empty($nestedSelections))) { + if ($this->resolveRelationships && !empty($relationships) && (empty($selects) || !empty($nestedSelections))) { $document = $this->silent(fn () => $this->populateDocumentRelationships($collection, $document, $nestedSelections)); } @@ -6091,7 +6091,7 @@ public function find(string $collection, array $queries = [], string $forPermiss $results = $skipAuth ? Authorization::skip($getResults) : $getResults(); foreach ($results as &$node) { - if ($this->resolveRelationships && (empty($selects) || !empty($nestedSelections))) { + if ($this->resolveRelationships && !empty($relationships) && (empty($selects) || !empty($nestedSelections))) { $node = $this->silent(fn () => $this->populateDocumentRelationships($collection, $node, $nestedSelections)); } @@ -6802,7 +6802,9 @@ private function processRelationshipQueries( continue; } - $selectedKey = \explode('.', $value)[0]; + $nesting = \explode('.', $value); + + $selectedKey = $nesting[0]; $relationship = \array_values(\array_filter( $relationships, @@ -6816,7 +6818,7 @@ private function processRelationshipQueries( // Shift the top level off the dot-path to pass the selection down the chain // 'foo.bar.baz' becomes 'bar.baz' $nestedSelections[] = Query::select([ - \implode('.', \array_slice(\explode('.', $value), 1)) + \implode('.', \array_slice($nesting, 1)) ]); $type = $relationship->getAttribute('options')['relationType']; @@ -6845,6 +6847,7 @@ private function processRelationshipQueries( break; } } + $query->setValues(\array_values($values)); } diff --git a/tests/e2e/Adapter/Base.php b/tests/e2e/Adapter/Base.php index a57fe2748..19887adda 100644 --- a/tests/e2e/Adapter/Base.php +++ b/tests/e2e/Adapter/Base.php @@ -17,11 +17,11 @@ abstract class Base extends TestCase { - use CollectionTests; - use DocumentTests; - use AttributeTests; - use IndexTests; - use PermissionTests; + // use CollectionTests; + // use DocumentTests; + // use AttributeTests; + // use IndexTests; + // use PermissionTests; use RelationshipTests; use GeneralTests; diff --git a/tests/e2e/Adapter/Scopes/RelationshipTests.php b/tests/e2e/Adapter/Scopes/RelationshipTests.php index 9db9d5be2..5bdacd081 100644 --- a/tests/e2e/Adapter/Scopes/RelationshipTests.php +++ b/tests/e2e/Adapter/Scopes/RelationshipTests.php @@ -27,6 +27,215 @@ trait RelationshipTests use ManyToOneTests; use ManyToManyTests; + public function testZoo(): void + { + /** @var Database $database */ + $database = static::getDatabase(); + + if (!$database->getAdapter()->getSupportForRelationships()) { + $this->expectNotToPerformAssertions(); + return; + } + + $database->createCollection('zoo'); + $database->createAttribute('zoo', 'name', Database::VAR_STRING, 256, true); + + $database->createCollection('veterinarians'); + $database->createAttribute('veterinarians', 'fullname', Database::VAR_STRING, 256, true); + + + $database->createCollection('presidents'); + $database->createAttribute('presidents', 'first_name', Database::VAR_STRING, 256, true); + $database->createAttribute('presidents', 'last_name', Database::VAR_STRING, 256, true); + $database->createRelationship( + collection: 'presidents', + relatedCollection: 'veterinarians', + type: Database::RELATION_MANY_TO_MANY, + twoWay: true, + id: 'votes', + twoWayKey: 'presidents' + ); + + $database->createCollection('animals'); + $database->createAttribute('animals', 'name', Database::VAR_STRING, 256, true); + $database->createAttribute('animals', 'age', Database::VAR_INTEGER, 0, false); + $database->createAttribute('animals', 'price', Database::VAR_FLOAT, 0, false); + $database->createAttribute('animals', 'date_of_birth', Database::VAR_DATETIME, 0, true, filters:['datetime']); + $database->createAttribute('animals', 'longtext', Database::VAR_STRING, 100000000, false); + $database->createAttribute('animals', 'is_active', Database::VAR_BOOLEAN, 0, false, default: true); + $database->createAttribute('animals', 'integers', Database::VAR_INTEGER, 0, false, array: true); + $database->createAttribute('animals', 'email', Database::VAR_STRING, 255, false); + $database->createAttribute('animals', 'ip', Database::VAR_STRING, 255, false); + $database->createAttribute('animals', 'url', Database::VAR_STRING, 255, false); + $database->createAttribute('animals', 'enum', Database::VAR_STRING, 255, false); + + $database->createRelationship( + collection: 'presidents', + relatedCollection: 'animals', + type: Database::RELATION_ONE_TO_ONE, + twoWay: true, + id: 'animal', + twoWayKey: 'president' + ); + + $database->createRelationship( + collection: 'veterinarians', + relatedCollection: 'animals', + type: Database::RELATION_ONE_TO_MANY, + twoWay: true, + id: 'animals', + twoWayKey: 'veterinarian' + ); + + $database->createRelationship( + collection: 'animals', + relatedCollection: 'zoo', + type: Database::RELATION_MANY_TO_ONE, + twoWay: true, + id: 'zoo', + twoWayKey: 'animals' + ); + + $zoo1 = $database->createDocument('zoo', new Document([ + '$id' => 'zoo1', + '$permissions' => [ + Permission::read(Role::any()), + Permission::update(Role::any()), + ], + 'name' => 'Bronx Zoo' + ])); + + $animal1 = $database->createDocument('animals', new Document([ + '$id' => 'iguana', + '$permissions' => [ + Permission::read(Role::any()), + Permission::update(Role::any()), + ], + 'name' => 'Iguana', + 'age' => 11, + 'price' => 50.5, + 'date_of_birth' => '1975-06-12', + 'longtext' => 'I am a pretty long text', + 'is_active' => true, + 'integers' => [1, 2, 3], + 'email' => 'iguana@appwrite.io', + 'enum' => 'maybe', + 'ip' => '127.0.0.1', + 'url' => 'https://appwrite.io/', + 'zoo' => $zoo1->getId(), + ])); + + $animal2 = $database->createDocument('animals', new Document([ + '$id' => 'tiger', + '$permissions' => [ + Permission::read(Role::any()), + Permission::update(Role::any()), + ], + 'name' => 'Tiger', + 'age' => 5, + 'price' => 1000, + 'date_of_birth' => '2020-06-12', + 'longtext' => 'I am a hungry tiger', + 'is_active' => false, + 'integers' => [9, 2, 3], + 'email' => 'tiger@appwrite.io', + 'enum' => 'yes', + 'ip' => '255.0.0.1', + 'url' => 'https://appwrite.io/', + 'zoo' => $zoo1->getId(), + ])); + + $animal3 = $database->createDocument('animals', new Document([ + '$id' => 'lama', + '$permissions' => [ + Permission::read(Role::any()), + Permission::update(Role::any()), + ], + 'name' => 'Lama', + 'age' => 15, + 'price' => 1000, + 'date_of_birth' => '1975-06-12', + 'is_active' => true, + 'integers' => null, + 'email' => null, + 'enum' => null, + 'ip' => '255.0.0.1', + 'url' => 'https://appwrite.io/', + 'zoo' => null, + ])); + + $veterinarian1 = $database->createDocument('veterinarians', new Document([ + '$id' => 'dr.pol', + '$permissions' => [ + Permission::read(Role::any()), + Permission::update(Role::any()), + ], + 'fullname' => 'The Incredible Dr. Pol', + 'animals' => ['iguana'], + ])); + + $veterinarian2 = $database->createDocument('veterinarians', new Document([ + '$id' => 'dr.seuss', + '$permissions' => [ + Permission::read(Role::any()), + Permission::update(Role::any()), + ], + 'fullname' => 'Dr. Seuss', + 'animals' => ['tiger'], + ])); + + $president1 = $database->createDocument('presidents', new Document([ + '$id' => 'trump', + '$permissions' => [ + Permission::read(Role::any()), + Permission::update(Role::any()), + ], + 'first_name' => 'Donald', + 'last_name' => 'Trump', + 'votes' => [ + $veterinarian1->getId(), + $veterinarian2->getId(), + ], + ])); + + $president2 = $database->createDocument('presidents', new Document([ + '$id' => 'bush', + '$permissions' => [ + Permission::read(Role::any()), + Permission::update(Role::any()), + ], + 'first_name' => 'George', + 'last_name' => 'Bush', + 'animal' => 'iguana', + ])); + + $president3 = $database->createDocument('presidents', new Document([ + '$id' => 'biden', + '$permissions' => [ + Permission::read(Role::any()), + Permission::update(Role::any()), + ], + 'first_name' => 'Joe', + 'last_name' => 'Biden', + 'animal' => 'tiger', + ])); + + var_dump('===start'); + + $docs = $database->find('veterinarians', + [ + Query::select([ + '*', + 'animals.*', + 'animals.zoo.*', + //'animals.president.*', + ]) + ] + ); + + $this->assertEquals('shmuel', 'fogel'); + } + public function testDeleteRelatedCollection(): void { /** @var Database $database */ From fd2120c9dba22e0aa85eb74f7a62c27418ea0ae6 Mon Sep 17 00:00:00 2001 From: fogelito Date: Wed, 30 Jul 2025 17:51:03 +0300 Subject: [PATCH 02/13] dbg --- src/Database/Database.php | 2 ++ tests/e2e/Adapter/Scopes/RelationshipTests.php | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Database/Database.php b/src/Database/Database.php index 38ff70c29..cd19adb71 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -3527,6 +3527,8 @@ private function populateDocumentRelationships(Document $collection, Document $d $related = []; if (!empty($relatedIds)) { + //var_dump($queries); + $foundRelated = $this->find($relatedCollection->getId(), [ Query::equal('$id', $relatedIds), Query::limit(PHP_INT_MAX), diff --git a/tests/e2e/Adapter/Scopes/RelationshipTests.php b/tests/e2e/Adapter/Scopes/RelationshipTests.php index 5bdacd081..c2629a751 100644 --- a/tests/e2e/Adapter/Scopes/RelationshipTests.php +++ b/tests/e2e/Adapter/Scopes/RelationshipTests.php @@ -43,7 +43,6 @@ public function testZoo(): void $database->createCollection('veterinarians'); $database->createAttribute('veterinarians', 'fullname', Database::VAR_STRING, 256, true); - $database->createCollection('presidents'); $database->createAttribute('presidents', 'first_name', Database::VAR_STRING, 256, true); $database->createAttribute('presidents', 'last_name', Database::VAR_STRING, 256, true); @@ -220,7 +219,7 @@ public function testZoo(): void 'animal' => 'tiger', ])); - var_dump('===start'); + var_dump('=== start === === start === === start === === start === === start === === start === === start === === start === === start ==='); $docs = $database->find('veterinarians', [ From f655f6f1a4b5a481d798abaa0a3ae8d99f5beecd Mon Sep 17 00:00:00 2001 From: fogelito Date: Wed, 30 Jul 2025 18:02:00 +0300 Subject: [PATCH 03/13] Remove reference --- src/Database/Database.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Database/Database.php b/src/Database/Database.php index cd19adb71..86bbee82e 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -6092,7 +6092,7 @@ public function find(string $collection, array $queries = [], string $forPermiss $results = $skipAuth ? Authorization::skip($getResults) : $getResults(); - foreach ($results as &$node) { + foreach ($results as $index => $node) { if ($this->resolveRelationships && !empty($relationships) && (empty($selects) || !empty($nestedSelections))) { $node = $this->silent(fn () => $this->populateDocumentRelationships($collection, $node, $nestedSelections)); } @@ -6103,6 +6103,8 @@ public function find(string $collection, array $queries = [], string $forPermiss if (!$node->isEmpty()) { $node->setAttribute('$collection', $collection->getId()); } + + $results[$index] = $node; } $this->trigger(self::EVENT_DOCUMENT_FIND, $results); From 91d2a6fcd3cba24d2c45fbd435aaae8840b9ac08 Mon Sep 17 00:00:00 2001 From: fogelito Date: Wed, 30 Jul 2025 18:06:06 +0300 Subject: [PATCH 04/13] Remove reference --- src/Database/Database.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Database/Database.php b/src/Database/Database.php index 86bbee82e..08c5f6482 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -6349,11 +6349,12 @@ public function encode(Document $collection, Document $document): Document $value = ($array) ? $value : [$value]; } - foreach ($value as &$node) { - if (($node !== null)) { + foreach ($value as $index => $node) { + if ($node !== null) { foreach ($filters as $filter) { $node = $this->encodeAttribute($filter, $node, $document); } + $value[$index] = $node; } } From 3c28b5c9dbcc6fd9dd1b188a2dd5c792a33917f4 Mon Sep 17 00:00:00 2001 From: fogelito Date: Wed, 30 Jul 2025 19:07:21 +0300 Subject: [PATCH 05/13] dbg --- src/Database/Database.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Database/Database.php b/src/Database/Database.php index 08c5f6482..4ced8efab 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -6808,8 +6808,7 @@ private function processRelationshipQueries( } $nesting = \explode('.', $value); - - $selectedKey = $nesting[0]; + $selectedKey = \array_shift($nesting); // Removes and return first item $relationship = \array_values(\array_filter( $relationships, @@ -6823,12 +6822,18 @@ private function processRelationshipQueries( // Shift the top level off the dot-path to pass the selection down the chain // 'foo.bar.baz' becomes 'bar.baz' $nestedSelections[] = Query::select([ - \implode('.', \array_slice($nesting, 1)) + \implode('.', $nesting) ]); $type = $relationship->getAttribute('options')['relationType']; $side = $relationship->getAttribute('options')['side']; + var_dump('=========== in ========'); + var_dump($selectedKey); + var_dump($nesting); + var_dump($type); + var_dump($side); + switch ($type) { case Database::RELATION_MANY_TO_MANY: unset($values[$valueIndex]); From eb283984fdb472806f8e6df47e77bea225216e94 Mon Sep 17 00:00:00 2001 From: fogelito Date: Wed, 30 Jul 2025 19:07:59 +0300 Subject: [PATCH 06/13] dbg --- src/Database/Database.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Database/Database.php b/src/Database/Database.php index 4ced8efab..99c917f2c 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -6808,7 +6808,7 @@ private function processRelationshipQueries( } $nesting = \explode('.', $value); - $selectedKey = \array_shift($nesting); // Removes and return first item + $selectedKey = \array_shift($nesting); // Remove and return first item $relationship = \array_values(\array_filter( $relationships, From db3d9992b83cc5a815cfaa3665a61f1de9771119 Mon Sep 17 00:00:00 2001 From: fogelito Date: Thu, 31 Jul 2025 09:55:52 +0300 Subject: [PATCH 07/13] dbg --- src/Database/Database.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Database/Database.php b/src/Database/Database.php index 99c917f2c..eb39d715c 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -6821,9 +6821,9 @@ private function processRelationshipQueries( // Shift the top level off the dot-path to pass the selection down the chain // 'foo.bar.baz' becomes 'bar.baz' - $nestedSelections[] = Query::select([ - \implode('.', $nesting) - ]); + + $nestingPath = \implode('.', $nesting); + $nestedSelections[] = Query::select([$nestingPath]); $type = $relationship->getAttribute('options')['relationType']; $side = $relationship->getAttribute('options')['side']; From 5866fd56bc44cfb919a8e1d53536f9132af42806 Mon Sep 17 00:00:00 2001 From: fogelito Date: Thu, 31 Jul 2025 09:56:20 +0300 Subject: [PATCH 08/13] dbg --- src/Database/Database.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/Database/Database.php b/src/Database/Database.php index eb39d715c..37fb34133 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -6828,12 +6828,6 @@ private function processRelationshipQueries( $type = $relationship->getAttribute('options')['relationType']; $side = $relationship->getAttribute('options')['side']; - var_dump('=========== in ========'); - var_dump($selectedKey); - var_dump($nesting); - var_dump($type); - var_dump($side); - switch ($type) { case Database::RELATION_MANY_TO_MANY: unset($values[$valueIndex]); From c2556b1554d03662c1e33202fa39d5c0c5dd87db Mon Sep 17 00:00:00 2001 From: fogelito Date: Thu, 31 Jul 2025 12:27:02 +0300 Subject: [PATCH 09/13] Breakthrough? --- src/Database/Database.php | 16 +++++--- .../e2e/Adapter/Scopes/RelationshipTests.php | 39 ++++++++++--------- 2 files changed, 30 insertions(+), 25 deletions(-) diff --git a/src/Database/Database.php b/src/Database/Database.php index 37fb34133..35e2eaaec 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -3310,11 +3310,11 @@ public function getDocument(string $collection, string $id, array $queries = [], /** * @param Document $collection * @param Document $document - * @param array $queries + * @param array> $selects * @return Document * @throws DatabaseException */ - private function populateDocumentRelationships(Document $collection, Document $document, array $queries = []): Document + private function populateDocumentRelationships(Document $collection, Document $document, array $selects = []): Document { $attributes = $collection->getAttribute('attributes', []); @@ -3331,6 +3331,8 @@ private function populateDocumentRelationships(Document $collection, Document $d $twoWayKey = $relationship['options']['twoWayKey']; $side = $relationship['options']['side']; + $queries = $selects[$key] ?? []; + if (!empty($value)) { $k = $relatedCollection->getId() . ':' . $value . '=>' . $collection->getId() . ':' . $document->getId(); if ($relationType === Database::RELATION_ONE_TO_MANY) { @@ -3527,8 +3529,6 @@ private function populateDocumentRelationships(Document $collection, Document $d $related = []; if (!empty($relatedIds)) { - //var_dump($queries); - $foundRelated = $this->find($relatedCollection->getId(), [ Query::equal('$id', $relatedIds), Query::limit(PHP_INT_MAX), @@ -6788,7 +6788,7 @@ private function checkQueriesType(array $queries): void * * @param array $relationships * @param array $queries - * @return array + * @return array> $selects */ private function processRelationshipQueries( array $relationships, @@ -6823,7 +6823,7 @@ private function processRelationshipQueries( // 'foo.bar.baz' becomes 'bar.baz' $nestingPath = \implode('.', $nesting); - $nestedSelections[] = Query::select([$nestingPath]); + $nestedSelections[$selectedKey][] = Query::select([$nestingPath]); $type = $relationship->getAttribute('options')['relationType']; $side = $relationship->getAttribute('options')['side']; @@ -6855,6 +6855,10 @@ private function processRelationshipQueries( $query->setValues(\array_values($values)); } + if(!empty($nestedSelections)){ + var_dump('$nestedSelections$nestedSelections$nestedSelections$nestedSelections$nestedSelections$nestedSelections$nestedSelections$nestedSelections'); + var_dump($nestedSelections); + } return $nestedSelections; } } diff --git a/tests/e2e/Adapter/Scopes/RelationshipTests.php b/tests/e2e/Adapter/Scopes/RelationshipTests.php index c2629a751..1dab73d35 100644 --- a/tests/e2e/Adapter/Scopes/RelationshipTests.php +++ b/tests/e2e/Adapter/Scopes/RelationshipTests.php @@ -55,22 +55,22 @@ public function testZoo(): void twoWayKey: 'presidents' ); - $database->createCollection('animals'); - $database->createAttribute('animals', 'name', Database::VAR_STRING, 256, true); - $database->createAttribute('animals', 'age', Database::VAR_INTEGER, 0, false); - $database->createAttribute('animals', 'price', Database::VAR_FLOAT, 0, false); - $database->createAttribute('animals', 'date_of_birth', Database::VAR_DATETIME, 0, true, filters:['datetime']); - $database->createAttribute('animals', 'longtext', Database::VAR_STRING, 100000000, false); - $database->createAttribute('animals', 'is_active', Database::VAR_BOOLEAN, 0, false, default: true); - $database->createAttribute('animals', 'integers', Database::VAR_INTEGER, 0, false, array: true); - $database->createAttribute('animals', 'email', Database::VAR_STRING, 255, false); - $database->createAttribute('animals', 'ip', Database::VAR_STRING, 255, false); - $database->createAttribute('animals', 'url', Database::VAR_STRING, 255, false); - $database->createAttribute('animals', 'enum', Database::VAR_STRING, 255, false); + $database->createCollection('__animals'); + $database->createAttribute('__animals', 'name', Database::VAR_STRING, 256, true); + $database->createAttribute('__animals', 'age', Database::VAR_INTEGER, 0, false); + $database->createAttribute('__animals', 'price', Database::VAR_FLOAT, 0, false); + $database->createAttribute('__animals', 'date_of_birth', Database::VAR_DATETIME, 0, true, filters:['datetime']); + $database->createAttribute('__animals', 'longtext', Database::VAR_STRING, 100000000, false); + $database->createAttribute('__animals', 'is_active', Database::VAR_BOOLEAN, 0, false, default: true); + $database->createAttribute('__animals', 'integers', Database::VAR_INTEGER, 0, false, array: true); + $database->createAttribute('__animals', 'email', Database::VAR_STRING, 255, false); + $database->createAttribute('__animals', 'ip', Database::VAR_STRING, 255, false); + $database->createAttribute('__animals', 'url', Database::VAR_STRING, 255, false); + $database->createAttribute('__animals', 'enum', Database::VAR_STRING, 255, false); $database->createRelationship( collection: 'presidents', - relatedCollection: 'animals', + relatedCollection: '__animals', type: Database::RELATION_ONE_TO_ONE, twoWay: true, id: 'animal', @@ -79,7 +79,7 @@ public function testZoo(): void $database->createRelationship( collection: 'veterinarians', - relatedCollection: 'animals', + relatedCollection: '__animals', type: Database::RELATION_ONE_TO_MANY, twoWay: true, id: 'animals', @@ -87,7 +87,7 @@ public function testZoo(): void ); $database->createRelationship( - collection: 'animals', + collection: '__animals', relatedCollection: 'zoo', type: Database::RELATION_MANY_TO_ONE, twoWay: true, @@ -104,7 +104,7 @@ public function testZoo(): void 'name' => 'Bronx Zoo' ])); - $animal1 = $database->createDocument('animals', new Document([ + $animal1 = $database->createDocument('__animals', new Document([ '$id' => 'iguana', '$permissions' => [ Permission::read(Role::any()), @@ -124,7 +124,7 @@ public function testZoo(): void 'zoo' => $zoo1->getId(), ])); - $animal2 = $database->createDocument('animals', new Document([ + $animal2 = $database->createDocument('__animals', new Document([ '$id' => 'tiger', '$permissions' => [ Permission::read(Role::any()), @@ -144,7 +144,7 @@ public function testZoo(): void 'zoo' => $zoo1->getId(), ])); - $animal3 = $database->createDocument('animals', new Document([ + $animal3 = $database->createDocument('__animals', new Document([ '$id' => 'lama', '$permissions' => [ Permission::read(Role::any()), @@ -231,8 +231,9 @@ public function testZoo(): void ]) ] ); +var_dump($docs); - $this->assertEquals('shmuel', 'fogel'); + $this->assertEquals('shmuel', 'fogel'); } public function testDeleteRelatedCollection(): void From 40389f5eb0640a55cffa2e9d03c187f27492284e Mon Sep 17 00:00:00 2001 From: fogelito Date: Thu, 31 Jul 2025 12:28:22 +0300 Subject: [PATCH 10/13] Breakthrough? --- tests/e2e/Adapter/Base.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/e2e/Adapter/Base.php b/tests/e2e/Adapter/Base.php index 19887adda..ab1998dc7 100644 --- a/tests/e2e/Adapter/Base.php +++ b/tests/e2e/Adapter/Base.php @@ -17,11 +17,11 @@ abstract class Base extends TestCase { - // use CollectionTests; - // use DocumentTests; - // use AttributeTests; - // use IndexTests; - // use PermissionTests; + use CollectionTests; + use DocumentTests; + use AttributeTests; + use IndexTests; + use PermissionTests; use RelationshipTests; use GeneralTests; From 069b2f838cabf52d06525de9a3515877ea302156 Mon Sep 17 00:00:00 2001 From: fogelito Date: Thu, 31 Jul 2025 12:28:43 +0300 Subject: [PATCH 11/13] Tests --- tests/e2e/Adapter/Base.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/e2e/Adapter/Base.php b/tests/e2e/Adapter/Base.php index ab1998dc7..a57fe2748 100644 --- a/tests/e2e/Adapter/Base.php +++ b/tests/e2e/Adapter/Base.php @@ -17,11 +17,11 @@ abstract class Base extends TestCase { - use CollectionTests; - use DocumentTests; - use AttributeTests; - use IndexTests; - use PermissionTests; + use CollectionTests; + use DocumentTests; + use AttributeTests; + use IndexTests; + use PermissionTests; use RelationshipTests; use GeneralTests; From 47ad71625b50af23b7c63e1908e781f6145ce105 Mon Sep 17 00:00:00 2001 From: fogelito Date: Thu, 31 Jul 2025 12:29:03 +0300 Subject: [PATCH 12/13] formatting --- src/Database/Database.php | 2 +- tests/e2e/Adapter/Scopes/RelationshipTests.php | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Database/Database.php b/src/Database/Database.php index 35e2eaaec..dfeafafa1 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -6855,7 +6855,7 @@ private function processRelationshipQueries( $query->setValues(\array_values($values)); } - if(!empty($nestedSelections)){ + if (!empty($nestedSelections)) { var_dump('$nestedSelections$nestedSelections$nestedSelections$nestedSelections$nestedSelections$nestedSelections$nestedSelections$nestedSelections'); var_dump($nestedSelections); } diff --git a/tests/e2e/Adapter/Scopes/RelationshipTests.php b/tests/e2e/Adapter/Scopes/RelationshipTests.php index 1dab73d35..db3ba3c9f 100644 --- a/tests/e2e/Adapter/Scopes/RelationshipTests.php +++ b/tests/e2e/Adapter/Scopes/RelationshipTests.php @@ -221,7 +221,8 @@ public function testZoo(): void var_dump('=== start === === start === === start === === start === === start === === start === === start === === start === === start ==='); - $docs = $database->find('veterinarians', + $docs = $database->find( + 'veterinarians', [ Query::select([ '*', @@ -231,9 +232,9 @@ public function testZoo(): void ]) ] ); -var_dump($docs); + var_dump($docs); - $this->assertEquals('shmuel', 'fogel'); + $this->assertEquals('shmuel', 'fogel'); } public function testDeleteRelatedCollection(): void From 153fe2c0e0a4e3324aef4fa4e0344da6517118f9 Mon Sep 17 00:00:00 2001 From: fogelito Date: Thu, 31 Jul 2025 16:19:47 +0300 Subject: [PATCH 13/13] Run tests --- src/Database/Database.php | 4 ---- tests/e2e/Adapter/Scopes/RelationshipTests.php | 3 ++- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Database/Database.php b/src/Database/Database.php index dfeafafa1..a1573a7b0 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -6855,10 +6855,6 @@ private function processRelationshipQueries( $query->setValues(\array_values($values)); } - if (!empty($nestedSelections)) { - var_dump('$nestedSelections$nestedSelections$nestedSelections$nestedSelections$nestedSelections$nestedSelections$nestedSelections$nestedSelections'); - var_dump($nestedSelections); - } return $nestedSelections; } } diff --git a/tests/e2e/Adapter/Scopes/RelationshipTests.php b/tests/e2e/Adapter/Scopes/RelationshipTests.php index db3ba3c9f..edc2f3e0b 100644 --- a/tests/e2e/Adapter/Scopes/RelationshipTests.php +++ b/tests/e2e/Adapter/Scopes/RelationshipTests.php @@ -232,9 +232,10 @@ public function testZoo(): void ]) ] ); + var_dump($docs); - $this->assertEquals('shmuel', 'fogel'); + //$this->assertEquals('shmuel', 'fogel'); } public function testDeleteRelatedCollection(): void