Skip to content

Commit 54e8e36

Browse files
abnegateclaude
andcommitted
fix: force $sequence to VAR_INTEGER and accept integer IDs in UUID7 mode
- Structure validator: force $sequence (not $tenant) to VAR_INTEGER since sequences are always auto-incrementing integers - Sequence validator: fall through from UUID7 to integer validation so VAR_ID attributes like $tenant can be integers in any adapter Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c74b8f0 commit 54e8e36

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/Database/Validator/Sequence.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,12 @@ public function isValid($value): bool
5050
}
5151

5252
switch ($this->idAttributeType) {
53-
case Database::VAR_UUID7: //UUID7
54-
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;
53+
case Database::VAR_UUID7:
54+
if (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) {
55+
return true;
56+
}
57+
// Also accept integer IDs (e.g. $tenant may be an integer in any adapter)
58+
// no break
5559
case Database::VAR_INTEGER:
5660
$start = ($this->primary) ? 1 : 0;
5761
$validator = new Range($start, Database::MAX_BIG_INT, Database::VAR_INTEGER);

src/Database/Validator/Structure.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ protected function checkForInvalidAttributeValues(array $structure, array $keys)
340340

341341
switch ($type) {
342342
case Database::VAR_ID:
343-
$idType = ($attribute['$id'] === '$tenant') ? Database::VAR_INTEGER : $this->idAttributeType;
343+
$idType = ($attribute['$id'] === '$sequence') ? Database::VAR_INTEGER : $this->idAttributeType;
344344
$validators[] = new Sequence($idType, $attribute['$id'] === '$sequence');
345345
break;
346346

0 commit comments

Comments
 (0)