Skip to content

Commit 372e622

Browse files
abnegateclaude
andcommitted
fix: use loose comparison for tenant checks to handle int/string mismatch
The casting() method converts VAR_ID to string on read, but setTenant() accepts int|string. Strict !== comparison between document tenant (string after casting) and adapter tenant (int) caused "Collection not found" errors in shared tables mode. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 280432a commit 372e622

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/Database/Database.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1856,7 +1856,7 @@ public function updateCollection(string $id, array $permissions, bool $documentS
18561856

18571857
if (
18581858
$this->adapter->getSharedTables()
1859-
&& $collection->getTenant() !== $this->adapter->getTenant()
1859+
&& $collection->getTenant() != $this->adapter->getTenant()
18601860
) {
18611861
throw new NotFoundException('Collection not found');
18621862
}
@@ -1892,7 +1892,7 @@ public function getCollection(string $id): Document
18921892
$id !== self::METADATA
18931893
&& $this->adapter->getSharedTables()
18941894
&& $collection->getTenant() !== null
1895-
&& $collection->getTenant() !== $this->adapter->getTenant()
1895+
&& $collection->getTenant() != $this->adapter->getTenant()
18961896
) {
18971897
return new Document();
18981898
}
@@ -1947,7 +1947,7 @@ public function getSizeOfCollection(string $collection): int
19471947
throw new NotFoundException('Collection not found');
19481948
}
19491949

1950-
if ($this->adapter->getSharedTables() && $collection->getTenant() !== $this->adapter->getTenant()) {
1950+
if ($this->adapter->getSharedTables() && $collection->getTenant() != $this->adapter->getTenant()) {
19511951
throw new NotFoundException('Collection not found');
19521952
}
19531953

@@ -1973,7 +1973,7 @@ public function getSizeOfCollectionOnDisk(string $collection): int
19731973
throw new NotFoundException('Collection not found');
19741974
}
19751975

1976-
if ($this->adapter->getSharedTables() && $collection->getTenant() !== $this->adapter->getTenant()) {
1976+
if ($this->adapter->getSharedTables() && $collection->getTenant() != $this->adapter->getTenant()) {
19771977
throw new NotFoundException('Collection not found');
19781978
}
19791979

@@ -2007,7 +2007,7 @@ public function deleteCollection(string $id): bool
20072007
throw new NotFoundException('Collection not found');
20082008
}
20092009

2010-
if ($this->adapter->getSharedTables() && $collection->getTenant() !== $this->adapter->getTenant()) {
2010+
if ($this->adapter->getSharedTables() && $collection->getTenant() != $this->adapter->getTenant()) {
20112011
throw new NotFoundException('Collection not found');
20122012
}
20132013

@@ -7201,7 +7201,7 @@ public function upsertDocumentsWithIncrease(
72017201
if ($document->getTenant() === null) {
72027202
throw new DatabaseException('Missing tenant. Tenant must be set when tenant per document is enabled.');
72037203
}
7204-
if (!$old->isEmpty() && $old->getTenant() !== $document->getTenant()) {
7204+
if (!$old->isEmpty() && $old->getTenant() != $document->getTenant()) {
72057205
throw new DatabaseException('Tenant cannot be changed.');
72067206
}
72077207
} else {

0 commit comments

Comments
 (0)