Skip to content

Commit 906c03e

Browse files
committed
Revert "revert: remove extra Sequence validator changes that break MariaDB shared tables"
This reverts commit cd13c1d.
1 parent effba5a commit 906c03e

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/Database/Database.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6055,7 +6055,7 @@ public function updateDocument(string $collection, string $id, Document $documen
60556055
$document['$createdAt'] = ($createdAt === null || !$this->preserveDates) ? $old->getCreatedAt() : $createdAt;
60566056

60576057
if ($this->adapter->getSharedTables()) {
6058-
$document['$tenant'] = $old->getTenant(); // Make sure user doesn't switch tenant
6058+
$document['$tenant'] = $old->getAttribute('$tenant'); // Make sure user doesn't switch tenant
60596059
}
60606060
$document = new Document($document);
60616061

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);

0 commit comments

Comments
 (0)