From 6f9d4117175bd894450235ac749219a9fd11150d Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 13 Feb 2026 22:34:51 +1300 Subject: [PATCH] fix: always validate $sequence as integer regardless of adapter ID type The $sequence attribute is always an auto-incrementing integer, regardless of the database adapter's ID type. When the Sequence validator checks $sequence values (primary=true), it should always use integer Range validation instead of applying the adapter's ID type validation (e.g., UUID7 regex for MongoDB). This fixes Query::equal('$sequence', [...]) returning 400 on MongoDB adapters where getIdAttributeType() returns VAR_UUID7. Co-Authored-By: Claude Opus 4.6 --- src/Database/Validator/Sequence.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Database/Validator/Sequence.php b/src/Database/Validator/Sequence.php index d528cc4ea..07ac19281 100644 --- a/src/Database/Validator/Sequence.php +++ b/src/Database/Validator/Sequence.php @@ -45,12 +45,17 @@ public function isValid($value): bool return false; } + // $sequence is always an integer regardless of adapter ID type + if ($this->primary) { + $validator = new Range(1, Database::MAX_BIG_INT, Database::VAR_INTEGER); + return $validator->isValid($value); + } + switch ($this->idAttributeType) { case Database::VAR_UUID7: //UUID7 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; case Database::VAR_INTEGER: - $start = ($this->primary) ? 1 : 0; - $validator = new Range($start, Database::MAX_BIG_INT, Database::VAR_INTEGER); + $validator = new Range(0, Database::MAX_BIG_INT, Database::VAR_INTEGER); return $validator->isValid($value); default: