Skip to content

Commit d747ef0

Browse files
committed
update: simplify check.
1 parent 5f4dc3c commit d747ef0

1 file changed

Lines changed: 3 additions & 24 deletions

File tree

src/Database/Database.php

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,6 @@ class Database
335335

336336
protected bool $resolveRelationships = true;
337337

338-
protected bool $ignoreNestedQueries = false;
339-
340338
protected bool $checkRelationshipsExist = true;
341339

342340
protected int $relationshipFetchDepth = 1;
@@ -549,25 +547,6 @@ public function skipRelationships(callable $callback): mixed
549547
}
550548
}
551549

552-
/**
553-
* Ignore the nested `Query::select` for relationships and return all the related documents.
554-
*
555-
* @template T
556-
* @param callable(): T $callback
557-
* @return T
558-
*/
559-
public function ignoreNestedQueries(callable $callback): mixed
560-
{
561-
$previous = $this->ignoreNestedQueries;
562-
$this->ignoreNestedQueries = true;
563-
564-
try {
565-
return $callback();
566-
} finally {
567-
$this->ignoreNestedQueries = $previous;
568-
}
569-
}
570-
571550
public function skipRelationshipsExistCheck(callable $callback): mixed
572551
{
573552
$previous = $this->checkRelationshipsExist;
@@ -3095,7 +3074,7 @@ public function getDocument(string $collection, string $id, array $queries = [],
30953074
$document = $this->decode($collection, $document, $selections);
30963075
$this->map = [];
30973076

3098-
if ($this->resolveRelationships && ($this->ignoreNestedQueries || Query::hasNestedSelect($originalQueries))) {
3077+
if ($this->resolveRelationships && Query::hasNestedSelect($originalQueries)) {
30993078
$document = $this->silent(fn () => $this->populateDocumentRelationships($collection, $document, $originalQueries));
31003079
}
31013080

@@ -3155,7 +3134,7 @@ private function populateDocumentRelationships(Document $collection, Document $d
31553134
$selects = Query::filterSelectsByPrefix($queries, $key);
31563135

31573136
// Skip resolving if respecting nested queries AND no fields were selected
3158-
if (! $this->ignoreNestedQueries && empty($selects)) {
3137+
if (empty($selects)) {
31593138
$document->removeAttribute($key);
31603139
continue;
31613140
}
@@ -5816,7 +5795,7 @@ public function find(string $collection, array $queries = [], string $forPermiss
58165795
$results = $skipAuth ? Authorization::skip($getResults) : $getResults();
58175796

58185797
foreach ($results as &$node) {
5819-
if ($this->resolveRelationships && ($this->ignoreNestedQueries || Query::hasNestedSelect($originalQueries))) {
5798+
if ($this->resolveRelationships && Query::hasNestedSelect($originalQueries)) {
58205799
$node = $this->silent(fn () => $this->populateDocumentRelationships($collection, $node, $originalQueries));
58215800
}
58225801
$node = $this->casting($collection, $node);

0 commit comments

Comments
 (0)