Skip to content

Commit c74b8f0

Browse files
abnegateclaude
andcommitted
fix: resolve $tenant type mismatch in validation and update detection
- Structure validator: always validate $tenant as integer regardless of adapter ID type, since tenant IDs are integers in all adapters - updateDocument: use raw getAttribute instead of getTenant() to preserve the original type and avoid false change detection from int/string mismatch Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent dfeacb1 commit c74b8f0

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/Database/Database.php

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

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

src/Database/Validator/Structure.php

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

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

346347
case Database::VAR_VARCHAR:

0 commit comments

Comments
 (0)