Skip to content

Commit 644ba46

Browse files
committed
change join $collectionId
1 parent 5564abe commit 644ba46

5 files changed

Lines changed: 32 additions & 32 deletions

File tree

src/Database/Adapter/SQL.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3103,7 +3103,7 @@ public function find(
31033103
$sqlJoin = '';
31043104
foreach ($joins as $join) {
31053105
$permissions = '';
3106-
$collection = $join->getCollection();
3106+
$collection = $join->getCollectionId();
31073107
$collection = $this->filter($collection);
31083108

31093109
$skipAuth = $context->skipAuth($collection, $forPermission, $this->authorization);
@@ -3265,7 +3265,7 @@ public function count(QueryContext $context, ?int $max, array $filters, array $j
32653265
$sqlJoin = '';
32663266
foreach ($joins as $join) {
32673267
$permissions = '';
3268-
$collection = $join->getCollection();
3268+
$collection = $join->getCollectionId();
32693269
$collection = $this->filter($collection);
32703270

32713271
$skipAuth = $context->skipAuth($collection, Database::PERMISSION_READ, $this->authorization);

src/Database/Database.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7766,7 +7766,7 @@ public function find(string $collection, array $queries = [], string $forPermiss
77667766

77677767
foreach ($joins as $join) {
77687768
$context->add(
7769-
$this->silent(fn () => $this->getCollection($join->getCollection())),
7769+
$this->silent(fn () => $this->getCollection($join->getCollectionId())),
77707770
$join->getAlias()
77717771
);
77727772
}
@@ -8021,7 +8021,7 @@ public function count(string $collection, array $queries = [], ?int $max = null)
80218021

80228022
foreach ($joins as $join) {
80238023
$context->add(
8024-
$this->silent(fn () => $this->getCollection($join->getCollection())),
8024+
$this->silent(fn () => $this->getCollection($join->getCollectionId())),
80258025
$join->getAlias()
80268026
);
80278027
}

src/Database/Query.php

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ class Query
185185
];
186186

187187
protected string $method = '';
188-
protected string $collection = '';
188+
protected string $collectionId = '';
189189
protected string $alias = '';
190190
protected string $attribute = '';
191191
protected string $attributeType = '';
@@ -214,7 +214,7 @@ protected function __construct(
214214
string $alias = '',
215215
string $attributeRight = '',
216216
string $aliasRight = '',
217-
string $collection = '',
217+
string $collectionId = '',
218218
string $as = '',
219219
bool $system = false,
220220
) {
@@ -239,7 +239,7 @@ protected function __construct(
239239
$this->values = $values;
240240
$this->aliasRight = $aliasRight;
241241
$this->attributeRight = $attributeRight;
242-
$this->collection = $collection;
242+
$this->collectionId = $collectionId;
243243
$this->as = $as;
244244
$this->system = $system;
245245
}
@@ -306,14 +306,14 @@ public function getAs(): string
306306
return $this->as;
307307
}
308308

309-
public function getCollection(): string
309+
public function getCollectionId(): string
310310
{
311-
return $this->collection;
311+
return $this->collectionId;
312312
}
313313

314-
public function setCollection(string $collection): self
314+
public function setCollection(string $collectionId): self
315315
{
316-
$this->collection = $collection;
316+
$this->collectionId = $collectionId;
317317

318318
return $this;
319319
}
@@ -541,7 +541,7 @@ public static function parseQuery(array $query): self
541541
$alias = $query['alias'] ?? '';
542542
$aliasRight = $query['aliasRight'] ?? '';
543543
$as = $query['as'] ?? '';
544-
$collection = $query['collection'] ?? '';
544+
$collectionId = $query['collectionId'] ?? '';
545545

546546
if (!\is_string($method)) {
547547
throw new QueryException('Invalid query method. Must be a string, got ' . \gettype($method));
@@ -572,7 +572,7 @@ public static function parseQuery(array $query): self
572572
alias: $alias,
573573
attributeRight: $attributeRight,
574574
aliasRight: $aliasRight,
575-
collection: $collection,
575+
collectionId: $collectionId,
576576
as: $as,
577577
);
578578
}
@@ -623,8 +623,8 @@ public function toArray(): array
623623
$array['as'] = $this->as;
624624
}
625625

626-
if (!empty($this->collection)) {
627-
$array['collection'] = $this->collection;
626+
if (!empty($this->collectionId)) {
627+
$array['collectionId'] = $this->collectionId;
628628
}
629629

630630
if ($this->isNested() || $this->isJoin()) {
@@ -1017,47 +1017,47 @@ public static function and(array $queries): self
10171017
}
10181018

10191019
/**
1020-
* @param string $collection
1020+
* @param string $collectionId
10211021
* @param string $alias
10221022
* @param array<Query> $queries
10231023
* @return self
10241024
*/
1025-
public static function join(string $collection, string $alias, array $queries = []): self
1025+
public static function join(string $collectionId, string $alias, array $queries = []): self
10261026
{
1027-
return new self(self::TYPE_INNER_JOIN, values: $queries, alias: $alias, collection: $collection);
1027+
return new self(self::TYPE_INNER_JOIN, values: $queries, alias: $alias, collectionId: $collectionId);
10281028
}
10291029

10301030
/**
1031-
* @param string $collection
1031+
* @param string $collectionId
10321032
* @param string $alias
10331033
* @param array<Query> $queries
10341034
* @return self
10351035
*/
1036-
public static function innerJoin(string $collection, string $alias, array $queries = []): self
1036+
public static function innerJoin(string $collectionId, string $alias, array $queries = []): self
10371037
{
1038-
return new self(self::TYPE_INNER_JOIN, values: $queries, alias: $alias, collection: $collection);
1038+
return new self(self::TYPE_INNER_JOIN, values: $queries, alias: $alias, collectionId: $collectionId);
10391039
}
10401040

10411041
/**
1042-
* @param string $collection
1042+
* @param string $collectionId
10431043
* @param string $alias
10441044
* @param array<Query> $queries
10451045
* @return self
10461046
*/
1047-
public static function leftJoin(string $collection, string $alias, array $queries = []): self
1047+
public static function leftJoin(string $collectionId, string $alias, array $queries = []): self
10481048
{
1049-
return new self(self::TYPE_LEFT_JOIN, values: $queries, alias: $alias, collection: $collection);
1049+
return new self(self::TYPE_LEFT_JOIN, values: $queries, alias: $alias, collectionId: $collectionId);
10501050
}
10511051

10521052
/**
1053-
* @param string $collection
1053+
* @param string $collectionId
10541054
* @param string $alias
10551055
* @param array<Query> $queries
10561056
* @return self
10571057
*/
1058-
public static function rightJoin(string $collection, string $alias, array $queries = []): self
1058+
public static function rightJoin(string $collectionId, string $alias, array $queries = []): self
10591059
{
1060-
return new self(self::TYPE_RIGHT_JOIN, values: $queries, alias: $alias, collection: $collection);
1060+
return new self(self::TYPE_RIGHT_JOIN, values: $queries, alias: $alias, collectionId: $collectionId);
10611061
}
10621062

10631063
public static function relationEqual(string $leftAlias, string $leftColumn, string $rightAlias, string $rightColumn): self

src/Database/Validator/Queries/V2.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ public function isValid($value, string $scope = ''): bool
316316
case Query::TYPE_INNER_JOIN:
317317
case Query::TYPE_LEFT_JOIN:
318318
case Query::TYPE_RIGHT_JOIN:
319-
if (($this->joinsCollectionsIds[$query->getCollection()] ?? false) !== true) {
319+
if (($this->joinsCollectionsIds[$query->getCollectionId()] ?? false) !== true) {
320320
throw new \Exception('Invalid query: Cannot ' . ucfirst($method) . ' this table.');
321321
}
322322

tests/unit/QueryTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ public function testJoins(): void
488488
);
489489

490490
$this->assertEquals(Query::TYPE_INNER_JOIN, $query->getMethod());
491-
$this->assertEquals('users', $query->getCollection());
491+
$this->assertEquals('users', $query->getCollectionId());
492492
$this->assertEquals('u', $query->getAlias());
493493
$this->assertCount(2, $query->getValues());
494494

@@ -539,7 +539,7 @@ public function testJoinsParse(): void
539539

540540
$join = Query::parse($string);
541541
$this->assertEquals('innerJoin', $join->getMethod());
542-
$this->assertEquals('users', $join->getCollection());
542+
$this->assertEquals('users', $join->getCollectionId());
543543

544544
$query = $join->getValues()[0];
545545
$this->assertEquals('relationEqual', $query->getMethod());
@@ -563,7 +563,7 @@ public function testJoinsParse(): void
563563

564564
$join = Query::parse($string);
565565
$this->assertEquals('leftJoin', $join->getMethod());
566-
$this->assertEquals('users', $join->getCollection());
566+
$this->assertEquals('users', $join->getCollectionId());
567567

568568
$query = $join->getValues()[0];
569569
$this->assertEquals('relationEqual', $query->getMethod());
@@ -587,7 +587,7 @@ public function testJoinsParse(): void
587587

588588
$join = Query::parse($string);
589589
$this->assertEquals('rightJoin', $join->getMethod());
590-
$this->assertEquals('users', $join->getCollection());
590+
$this->assertEquals('users', $join->getCollectionId());
591591

592592
$query = $join->getValues()[0];
593593
$this->assertEquals('relationEqual', $query->getMethod());

0 commit comments

Comments
 (0)