Skip to content

Commit 02d269d

Browse files
committed
addHiddenAttribute
1 parent 16c822e commit 02d269d

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

src/Database/Adapter/SQL.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1557,23 +1557,29 @@ public function getTenantQuery(
15571557
*/
15581558
protected function addHiddenAttribute(array $selects): string
15591559
{
1560-
$hash = [Query::DEFAULT_ALIAS];
1560+
$hash = [Query::DEFAULT_ALIAS => true];
15611561

15621562
foreach ($selects as $select) {
1563-
if (!in_array($select->getAlias(), $hash)){
1564-
$hash[] = $select->getAlias();
1563+
$alias = $select->getAlias();
1564+
if (!isset($hash[$alias])){
1565+
$hash[$alias] = true;
15651566
}
15661567
}
15671568

1569+
$hash = array_keys($hash);
1570+
15681571
$strings = [];
15691572

15701573
foreach ($hash as $alias) {
15711574
$strings[] = $alias.'._uid as '.$this->quote($alias.'::$id');
15721575
$strings[] = $alias.'._id as '.$this->quote($alias.'::$internalId');
1573-
$strings[] = $alias.'._tenant as '.$this->quote($alias.'::$tenant');
15741576
$strings[] = $alias.'._permissions as '.$this->quote($alias.'::$permissions');
15751577
$strings[] = $alias.'._createdAt as '.$this->quote($alias.'::$createdAt');
15761578
$strings[] = $alias.'._updatedAt as '.$this->quote($alias.'::$updatedAt');
1579+
1580+
if ($this->sharedTables) {
1581+
$strings[] = $alias.'._tenant as '.$this->quote($alias.'::$tenant');
1582+
}
15771583
}
15781584

15791585
return ', '.implode(', ', $strings);

tests/e2e/Adapter/Scopes/JoinsTests.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,14 @@ public function testJoin(): void
367367
$this->assertEquals('Invalid Query Select: Invalid "as" on attribute "*"', $e->getMessage());
368368
}
369369

370+
371+
$document = $db->getDocument(
372+
'__sessions',
373+
$session2->getId()
374+
);
375+
var_dump($document);
376+
$this->assertEquals('dsdsd', 'ds');
377+
370378
/**
371379
* Simple `as` query getDocument
372380
*/
@@ -414,8 +422,6 @@ public function testJoin(): void
414422
]
415423
);
416424

417-
var_dump($document);
418-
419425
$this->assertArrayHasKey('$permissions', $document);
420426
$this->assertArrayHasKey('$collection', $document);
421427
$this->assertArrayHasKey('___permissions', $document);
@@ -478,7 +484,6 @@ public function testJoin(): void
478484
$this->assertArrayHasKey('as_permissions', $document);
479485
$this->assertIsArray($document->getAttribute('as_permissions'));
480486

481-
$this->assertEquals('dsdsd', 'ds');
482487

483488

484489
// /**

0 commit comments

Comments
 (0)