Skip to content

Commit ca84265

Browse files
abnegateclaude
andcommitted
Allow array defaults for object attributes
Object types use arrays internally (like vectors and spatial types), so they should be allowed to have array default values. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent aeebd69 commit ca84265

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Database/Validator/Attribute.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,8 +464,8 @@ public function checkDefaultValue(Document $attribute): bool
464464
throw new DatabaseException($this->message);
465465
}
466466

467-
// Reject array defaults for non-array attributes (except vectors and spatial types which use arrays internally)
468-
if (\is_array($default) && !$array && !\in_array($type, [Database::VAR_VECTOR, ...Database::SPATIAL_TYPES], true)) {
467+
// Reject array defaults for non-array attributes (except vectors, spatial types, and objects which use arrays internally)
468+
if (\is_array($default) && !$array && !\in_array($type, [Database::VAR_VECTOR, Database::VAR_OBJECT, ...Database::SPATIAL_TYPES], true)) {
469469
$this->message = 'Cannot set an array default value for a non-array attribute';
470470
throw new DatabaseException($this->message);
471471
}

0 commit comments

Comments
 (0)