Skip to content

Commit 602eefc

Browse files
Refine BIGINT handling in Structure and Filter validators
- Updated validation logic to correctly determine bit size for VAR_BIGINT and VAR_INTEGER based on attribute size. - Ensured consistent handling of signed and unsigned integers across both validators.
1 parent f2acd8c commit 602eefc

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

src/Database/Validator/Query/Filter.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,10 @@ protected function isValidAttributeAndValues(string $attribute, array $values, s
153153
break;
154154

155155
case Database::VAR_INTEGER:
156+
case Database::VAR_BIGINT:
156157
$size = $attributeSchema['size'] ?? 4;
157158
$signed = $attributeSchema['signed'] ?? true;
158-
$bits = $size >= 8 ? 64 : 32;
159+
$bits = ($attributeType === Database::VAR_BIGINT || $size >= 8) ? 64 : 32;
159160
// For 64-bit unsigned, use signed since PHP doesn't support true 64-bit unsigned
160161
$unsigned = !$signed && $bits < 64;
161162
$validator = new Integer(false, $bits, $unsigned);

src/Database/Validator/Structure.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,13 +352,15 @@ protected function checkForInvalidAttributeValues(array $structure, array $keys)
352352
break;
353353

354354
case Database::VAR_INTEGER:
355+
case Database::VAR_BIGINT:
355356
// Determine bit size based on attribute size in bytes
356-
$bits = $size >= 8 ? 64 : 32;
357+
// BIGINT is always 64-bit in SQL adapters; VAR_INTEGER uses size to decide.
358+
$bits = ($type === Database::VAR_BIGINT || $size >= 8) ? 64 : 32;
357359
// For 64-bit unsigned, use signed since PHP doesn't support true 64-bit unsigned
358360
// The Range validator will restrict to positive values only
359361
$unsigned = !$signed && $bits < 64;
360362
$validators[] = new Integer(false, $bits, $unsigned);
361-
$max = $size >= 8 ? Database::MAX_BIG_INT : Database::MAX_INT;
363+
$max = $bits === 64 ? Database::MAX_BIG_INT : Database::MAX_INT;
362364
$min = $signed ? -$max : 0;
363365
$validators[] = new Range($min, $max, Database::VAR_INTEGER);
364366
break;

0 commit comments

Comments
 (0)