diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Action.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Action.php index 0d562a2894..e4c02b40ce 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Action.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Action.php @@ -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); diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/BigInt/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/BigInt/Create.php index 6991b8ac16..a7df055094 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/BigInt/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/BigInt/Create.php @@ -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, diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/BigInt/Update.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/BigInt/Update.php index 4c795527cb..5d8e8bf3a5 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/BigInt/Update.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/BigInt/Update.php @@ -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, diff --git a/src/Appwrite/Utopia/Response/Model/AttributeBigInt.php b/src/Appwrite/Utopia/Response/Model/AttributeBigInt.php index 9e0d918fe0..2ab02991cb 100644 --- a/src/Appwrite/Utopia/Response/Model/AttributeBigInt.php +++ b/src/Appwrite/Utopia/Response/Model/AttributeBigInt.php @@ -7,7 +7,7 @@ use Appwrite\Utopia\Response; class AttributeBigInt extends AttributeInteger { public array $conditions = [ - 'type' => self::TYPE_INTEGER, + 'type' => 'bigint', 'size' => 8, ]; diff --git a/src/Appwrite/Utopia/Response/Model/ColumnBigInt.php b/src/Appwrite/Utopia/Response/Model/ColumnBigInt.php index 9d7649f144..0d8b71ee98 100644 --- a/src/Appwrite/Utopia/Response/Model/ColumnBigInt.php +++ b/src/Appwrite/Utopia/Response/Model/ColumnBigInt.php @@ -7,7 +7,7 @@ use Appwrite\Utopia\Response; class ColumnBigInt extends ColumnInteger { public array $conditions = [ - 'type' => self::TYPE_INTEGER, + 'type' => 'bigint', 'size' => 8, ]; diff --git a/tests/e2e/Services/TablesDB/DatabasesNumericTypesTest.php b/tests/e2e/Services/TablesDB/DatabasesNumericTypesTest.php index 66f08e6000..614a8f1f34 100644 --- a/tests/e2e/Services/TablesDB/DatabasesNumericTypesTest.php +++ b/tests/e2e/Services/TablesDB/DatabasesNumericTypesTest.php @@ -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