Enhance BigInt support across database attributes and validation, updating types and tests for consistency.

This commit is contained in:
ArnabChatterjee20k
2026-03-30 17:45:25 +05:30
parent f6cdcfb823
commit 819863559e
6 changed files with 14 additions and 10 deletions
@@ -237,6 +237,10 @@ abstract class Action extends UtopiaAction
? UtopiaResponse::MODEL_ATTRIBUTE_BOOLEAN
: UtopiaResponse::MODEL_COLUMN_BOOLEAN,
Database::VAR_BIGINT => $isCollections
? UtopiaResponse::MODEL_ATTRIBUTE_BIGINT
: UtopiaResponse::MODEL_COLUMN_BIGINT,
Database::VAR_INTEGER => $isCollections
? UtopiaResponse::MODEL_ATTRIBUTE_INTEGER
: UtopiaResponse::MODEL_COLUMN_INTEGER,
@@ -549,7 +553,9 @@ abstract class Action extends UtopiaAction
}
if ($attribute->getAttribute('format') === APP_DATABASE_ATTRIBUTE_INT_RANGE) {
$validator = new Range($min, $max, Database::VAR_INTEGER);
// Use bigint validator when updating a bigint attribute/column.
$rangeType = $type === Database::VAR_BIGINT ? Database::VAR_BIGINT : Database::VAR_INTEGER;
$validator = new Range($min, $max, $rangeType);
} else {
$validator = new Range($min, $max, Database::VAR_FLOAT);
@@ -58,7 +58,6 @@ class Create extends Action
model: $this->getResponseModel(),
)
],
deprecated: new Deprecated(
deprecated: new Deprecated(
since: '1.8.0',
replaceWith: 'tablesDB.createBigIntColumn',
@@ -89,7 +88,7 @@ class Create extends Action
throw new Exception($this->getInvalidValueException(), 'Minimum value must be lesser than maximum value');
}
$validator = new Range($min, $max, Database::VAR_INTEGER);
$validator = new Range($min, $max, Database::VAR_BIGINT);
if (!\is_null($default) && !$validator->isValid($default)) {
throw new Exception($this->getInvalidValueException(), $validator->getDescription());
}
@@ -99,7 +98,7 @@ class Create extends Action
$attribute = $this->createAttribute($databaseId, $collectionId, new Document([
'key' => $key,
'type' => Database::VAR_INTEGER,
'type' => Database::VAR_BIGINT,
'size' => $size,
'required' => $required,
'default' => $default,
@@ -85,7 +85,7 @@ class Update extends Action
dbForProject: $dbForProject,
queueForEvents: $queueForEvents,
authorization: $authorization,
type: Database::VAR_INTEGER,
type: Database::VAR_BIGINT,
default: $default,
required: $required,
min: $min,
@@ -7,7 +7,7 @@ use Appwrite\Utopia\Response;
class AttributeBigInt extends AttributeInteger
{
public array $conditions = [
'type' => self::TYPE_INTEGER,
'type' => 'bigint',
'size' => 8,
];
@@ -7,7 +7,7 @@ use Appwrite\Utopia\Response;
class ColumnBigInt extends ColumnInteger
{
public array $conditions = [
'type' => self::TYPE_INTEGER,
'type' => 'bigint',
'size' => 8,
];
@@ -210,8 +210,7 @@ class DatabasesNumericTypesTest extends Scope
$this->assertEquals(200, $bigintColumn['headers']['status-code']);
$this->assertEquals('bigint_field', $bigintColumn['body']['key']);
// Some implementations may still represent bigint columns as integer internally.
$this->assertTrue(\in_array($bigintColumn['body']['type'], ['bigint', 'integer'], true));
$this->assertEquals('bigint', $bigintColumn['body']['type']);
$this->assertEquals(false, $bigintColumn['body']['required']);
$this->assertEquals(false, $bigintColumn['body']['array']);
$this->assertEquals(-900719925, $bigintColumn['body']['min']);
@@ -245,7 +244,7 @@ class DatabasesNumericTypesTest extends Scope
}
$this->assertEquals('integer', $columnTypeByKey['integer_field']);
$this->assertTrue(\in_array($columnTypeByKey['bigint_field'], ['bigint', 'integer'], true));
$this->assertEquals('bigint', $columnTypeByKey['bigint_field']);
}
public function testCreateRowWithIntegerAndBigIntTypes(): void