diff --git a/composer.lock b/composer.lock index 141ef45c01..bec82a1a4c 100644 --- a/composer.lock +++ b/composer.lock @@ -3854,12 +3854,12 @@ "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "17615116013c18b8f4d00246d52268ffbc15b11c" + "reference": "0e43fd44f2190da36cac816a17650d697e034507" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/17615116013c18b8f4d00246d52268ffbc15b11c", - "reference": "17615116013c18b8f4d00246d52268ffbc15b11c", + "url": "https://api.github.com/repos/utopia-php/database/zipball/0e43fd44f2190da36cac816a17650d697e034507", + "reference": "0e43fd44f2190da36cac816a17650d697e034507", "shasum": "" }, "require": { @@ -3905,7 +3905,7 @@ "issues": "https://github.com/utopia-php/database/issues", "source": "https://github.com/utopia-php/database/tree/big-init" }, - "time": "2026-04-09T05:22:46+00:00" + "time": "2026-04-09T11:05:50+00:00" }, { "name": "utopia-php/detector", 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 c0544fb122..4ea85b71e6 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 @@ -93,13 +93,10 @@ class Create extends Action throw new Exception($this->getInvalidValueException(), $validator->getDescription()); } - // `bigint` is always stored as a 64-bit integer. - $size = 8; - $attribute = $this->createAttribute($databaseId, $collectionId, new Document([ 'key' => $key, 'type' => Database::VAR_BIGINT, - 'size' => $size, + 'size' => 8, 'required' => $required, 'default' => $default, 'array' => $array, diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Create.php index 788222d4be..24cec35eac 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Create.php @@ -276,7 +276,16 @@ class Create extends Action ): array { $key = $attribute['key']; $type = $attribute['type']; - $size = $attribute['size'] ?? 0; + switch ($type) { + case Database::VAR_INTEGER: + $size = 4; + break; + case Database::VAR_BIGINT: + $size = 8; + break; + default: + $size = $attribute['size'] ?? 0; + } $required = $attribute['required'] ?? false; $signed = $attribute['signed'] ?? true; $array = $attribute['array'] ?? false; diff --git a/src/Appwrite/Utopia/Response/Model/AttributeBigInt.php b/src/Appwrite/Utopia/Response/Model/AttributeBigInt.php index 2ab02991cb..722bcedf5a 100644 --- a/src/Appwrite/Utopia/Response/Model/AttributeBigInt.php +++ b/src/Appwrite/Utopia/Response/Model/AttributeBigInt.php @@ -4,21 +4,56 @@ namespace Appwrite\Utopia\Response\Model; use Appwrite\Utopia\Response; -class AttributeBigInt extends AttributeInteger +class AttributeBigInt extends Attribute { - public array $conditions = [ - 'type' => 'bigint', - 'size' => 8, - ]; - public function __construct() { parent::__construct(); - // Update example for the `type` field - $this->rules['type']['example'] = 'bigint'; + $this + ->addRule('key', [ + 'type' => self::TYPE_STRING, + 'description' => 'Attribute Key.', + 'default' => '', + 'example' => 'count', + ]) + ->addRule('type', [ + 'type' => self::TYPE_STRING, + 'description' => 'Attribute type.', + 'default' => '', + 'example' => 'bigint', + ]) + ->addRule('min', [ + 'type' => self::TYPE_INTEGER, + 'format' => 'int64', + 'description' => 'Minimum value to enforce for new documents.', + 'default' => null, + 'required' => false, + 'example' => 1, + ]) + ->addRule('max', [ + 'type' => self::TYPE_INTEGER, + 'format' => 'int64', + 'description' => 'Maximum value to enforce for new documents.', + 'default' => null, + 'required' => false, + 'example' => 10, + ]) + ->addRule('default', [ + 'type' => self::TYPE_INTEGER, + 'description' => 'Default value for attribute when not provided. Cannot be set when attribute is required.', + 'default' => null, + 'required' => false, + 'example' => 10, + ]) + ; } + public array $conditions = [ + 'type' => 'bigint', + 'size' => 8, + ]; + public function getName(): string { return 'AttributeBigInt'; diff --git a/src/Appwrite/Utopia/Response/Model/ColumnBigInt.php b/src/Appwrite/Utopia/Response/Model/ColumnBigInt.php index 0d8b71ee98..c4d7f96586 100644 --- a/src/Appwrite/Utopia/Response/Model/ColumnBigInt.php +++ b/src/Appwrite/Utopia/Response/Model/ColumnBigInt.php @@ -4,21 +4,56 @@ namespace Appwrite\Utopia\Response\Model; use Appwrite\Utopia\Response; -class ColumnBigInt extends ColumnInteger +class ColumnBigInt extends Column { - public array $conditions = [ - 'type' => 'bigint', - 'size' => 8, - ]; - public function __construct() { parent::__construct(); - // Update example for the `type` field - $this->rules['type']['example'] = 'bigint'; + $this + ->addRule('key', [ + 'type' => self::TYPE_STRING, + 'description' => 'Column Key.', + 'default' => '', + 'example' => 'count', + ]) + ->addRule('type', [ + 'type' => self::TYPE_STRING, + 'description' => 'Column type.', + 'default' => '', + 'example' => 'bigint', + ]) + ->addRule('min', [ + 'type' => self::TYPE_INTEGER, + 'format' => 'int64', + 'description' => 'Minimum value to enforce for new documents.', + 'default' => null, + 'required' => false, + 'example' => 1, + ]) + ->addRule('max', [ + 'type' => self::TYPE_INTEGER, + 'format' => 'int64', + 'description' => 'Maximum value to enforce for new documents.', + 'default' => null, + 'required' => false, + 'example' => 10, + ]) + ->addRule('default', [ + 'type' => self::TYPE_INTEGER, + 'description' => 'Default value for column when not provided. Cannot be set when column is required.', + 'default' => null, + 'required' => false, + 'example' => 10, + ]) + ; } + public array $conditions = [ + 'type' => 'bigint', + 'size' => 8, + ]; + public function getName(): string { return 'ColumnBigInt';