Skip to content

Commit d9ef23f

Browse files
committed
(fix): Widen tenant type to int|string|null for MongoDB compatibility
1 parent c75b3c3 commit d9ef23f

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

src/Database/Adapter.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ abstract class Adapter
2323

2424
protected bool $sharedTables = false;
2525

26-
protected ?int $tenant = null;
26+
protected int|string|null $tenant = null;
2727

2828
protected bool $tenantPerDocument = false;
2929

@@ -219,11 +219,11 @@ public function getSharedTables(): bool
219219
*
220220
* Set tenant to use if tables are shared
221221
*
222-
* @param ?int $tenant
222+
* @param int|string|null $tenant
223223
*
224224
* @return bool
225225
*/
226-
public function setTenant(?int $tenant): bool
226+
public function setTenant(int|string|null $tenant): bool
227227
{
228228
$this->tenant = $tenant;
229229

@@ -235,9 +235,9 @@ public function setTenant(?int $tenant): bool
235235
*
236236
* Get tenant to use for shared tables
237237
*
238-
* @return ?int
238+
* @return int|string|null
239239
*/
240-
public function getTenant(): ?int
240+
public function getTenant(): int|string|null
241241
{
242242
return $this->tenant;
243243
}

src/Database/Adapter/Mongo.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3601,13 +3601,13 @@ public function getSchemaAttributes(string $collection): array
36013601

36023602
/**
36033603
* @param string $collection
3604-
* @param array<int> $tenants
3605-
* @return int|null|array<string, array<int>>
3604+
* @param array<int|string> $tenants
3605+
* @return int|string|null|array<string, array<int|string|null>>
36063606
*/
36073607
public function getTenantFilters(
36083608
string $collection,
36093609
array $tenants = [],
3610-
): int|null|array {
3610+
): int|string|null|array {
36113611
$values = [];
36123612
if (!$this->sharedTables) {
36133613
return $values;

src/Database/Document.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,17 +173,17 @@ public function getUpdatedAt(): ?string
173173
}
174174

175175
/**
176-
* @return int|null
176+
* @return int|string|null
177177
*/
178-
public function getTenant(): ?int
178+
public function getTenant(): int|string|null
179179
{
180180
$tenant = $this->getAttribute('$tenant');
181181

182-
if ($tenant === null) {
183-
return null;
182+
if (\is_numeric($tenant)) {
183+
return (int) $tenant;
184184
}
185185

186-
return (int) $tenant;
186+
return $tenant;
187187
}
188188

189189
/**

src/Database/Mirror.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public function setSharedTables(bool $sharedTables): static
123123
return $this;
124124
}
125125

126-
public function setTenant(?int $tenant): static
126+
public function setTenant(int|string|null $tenant): static
127127
{
128128
$this->delegate(__FUNCTION__, \func_get_args());
129129

0 commit comments

Comments
 (0)