mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Enhance BigInt support across database attributes and validation, updating types and tests for consistency.
This commit is contained in:
+7
-1
@@ -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);
|
||||
|
||||
|
||||
+2
-3
@@ -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,
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user