Skip to content

Commit b93a891

Browse files
committed
Merge branch 'fix-mongo-perms'
2 parents 1c768ad + 2522cb1 commit b93a891

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

src/Database/Database.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,7 @@ class Database
251251
],
252252
[
253253
'$id' => '$tenant',
254-
'type' => self::VAR_INTEGER,
255-
//'type' => self::VAR_ID, // Inconsistency with other VAR_ID since this is an INT
254+
'type' => self::VAR_ID,
256255
'size' => 0,
257256
'required' => false,
258257
'default' => null,
@@ -6055,7 +6054,7 @@ public function updateDocument(string $collection, string $id, Document $documen
60556054
$document['$createdAt'] = ($createdAt === null || !$this->preserveDates) ? $old->getCreatedAt() : $createdAt;
60566055

60576056
if ($this->adapter->getSharedTables()) {
6058-
$document['$tenant'] = $old->getTenant(); // Make sure user doesn't switch tenant
6057+
$document['$tenant'] = $old->getAttribute('$tenant'); // Make sure user doesn't switch tenant
60596058
}
60606059
$document = new Document($document);
60616060

src/Database/Validator/Sequence.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,17 @@ public function isValid($value): bool
4141
return false;
4242
}
4343

44-
if (!\is_string($value)) {
44+
if (!\is_string($value) && !\is_int($value)) {
4545
return false;
4646
}
4747

4848
switch ($this->idAttributeType) {
49-
case Database::VAR_UUID7: //UUID7
50-
return preg_match('/^[a-f0-9]{8}-[a-f0-9]{4}-7[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$/i', $value) === 1;
49+
case Database::VAR_UUID7:
50+
if (\is_string($value) && preg_match('/^[a-f0-9]{8}-[a-f0-9]{4}-7[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$/i', $value) === 1) {
51+
return true;
52+
}
53+
// Also accept integer IDs (e.g. $tenant may be an integer in any adapter)
54+
// no break
5155
case Database::VAR_INTEGER:
5256
$start = ($this->primary) ? 1 : 0;
5357
$validator = new Range($start, Database::MAX_BIG_INT, Database::VAR_INTEGER);

src/Database/Validator/Structure.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ class Structure extends Validator
5252
],
5353
[
5454
'$id' => '$tenant',
55-
'type' => Database::VAR_INTEGER, // ? VAR_ID
56-
'size' => 8,
55+
'type' => Database::VAR_ID,
56+
'size' => 0,
5757
'required' => false,
5858
'default' => null,
59-
'signed' => false,
59+
'signed' => true,
6060
'array' => false,
6161
'filters' => [],
6262
],

0 commit comments

Comments
 (0)