Skip to content

Commit 1968ec4

Browse files
github-actions[bot]claude
authored andcommitted
(fix): CI — pass signed flag to validateDefaultTypes for bigint defaults
validateDefaultTypes referenced an undefined $attribute variable when checking bigint string defaults, causing testCreateAttributesBigIntValidationSignedUnsignedAndMetadata to fail with "Undefined variable $attribute". Read signed from the Document in checkDefaultValue and thread it through validateDefaultTypes. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 2ae3837 commit 1968ec4

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/Database/Validator/Attribute.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,7 @@ public function checkDefaultValue(Document $attribute): bool
466466
$required = $attribute->getAttribute('required', false);
467467
$type = $attribute->getAttribute('type');
468468
$array = $attribute->getAttribute('array', false);
469+
$signed = $attribute->getAttribute('signed', true);
469470

470471
if (\is_null($default)) {
471472
return true;
@@ -482,7 +483,7 @@ public function checkDefaultValue(Document $attribute): bool
482483
throw new DatabaseException($this->message);
483484
}
484485

485-
$this->validateDefaultTypes($type, $default);
486+
$this->validateDefaultTypes($type, $default, $signed);
486487

487488
return true;
488489
}
@@ -492,11 +493,12 @@ public function checkDefaultValue(Document $attribute): bool
492493
*
493494
* @param string $type Type of the attribute
494495
* @param mixed $default Default value of the attribute
496+
* @param bool $signed Whether the attribute is signed (relevant for bigint)
495497
*
496498
* @return void
497499
* @throws DatabaseException
498500
*/
499-
protected function validateDefaultTypes(string $type, mixed $default): void
501+
protected function validateDefaultTypes(string $type, mixed $default, bool $signed = true): void
500502
{
501503
$defaultType = \gettype($default);
502504

@@ -509,7 +511,7 @@ protected function validateDefaultTypes(string $type, mixed $default): void
509511
// Spatial types require the array itself
510512
if (!in_array($type, Database::SPATIAL_TYPES) && $type != Database::VAR_OBJECT) {
511513
foreach ($default as $value) {
512-
$this->validateDefaultTypes($type, $value);
514+
$this->validateDefaultTypes($type, $value, $signed);
513515
}
514516
}
515517
return;
@@ -539,7 +541,7 @@ protected function validateDefaultTypes(string $type, mixed $default): void
539541
$this->message = 'Default value ' . $default . ' does not match given type ' . $type;
540542
throw new DatabaseException($this->message);
541543
}
542-
if ($defaultType === 'string' && !BigInt::isIntegerString($default, $attribute->getAttribute('signed', true))) {
544+
if ($defaultType === 'string' && !BigInt::isIntegerString($default, $signed)) {
543545
$this->message = 'Default value ' . $default . ' is not a valid integer string for type bigint';
544546
throw new DatabaseException($this->message);
545547
}

0 commit comments

Comments
 (0)