mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
(fix): use ColumnType::Double for float attributes and restore databaseId response key
Float attributes must use ColumnType::Double (value 'double') to match the existing AttributeFloat response model condition and Range validator. ColumnType::Float (value 'float') caused "Missing model" errors and Range validation failures. Also reverts Collection/Table response model rule keys from $databaseId back to databaseId since the Metadata decorator skips _metadata documents — collection responses use the non-prefixed key. Updates utopia-php/database with Attribute validator Float case fix. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
1f20a18587
commit
44d7591dd1
Generated
+8
-8
@@ -4038,12 +4038,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/database.git",
|
||||
"reference": "87a32dd262220cbc7d7d532d315331de19f376a2"
|
||||
"reference": "93b7f4d01a2b7794374d53b7d5cf8e4b9d2509fe"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/database/zipball/87a32dd262220cbc7d7d532d315331de19f376a2",
|
||||
"reference": "87a32dd262220cbc7d7d532d315331de19f376a2",
|
||||
"url": "https://api.github.com/repos/utopia-php/database/zipball/93b7f4d01a2b7794374d53b7d5cf8e4b9d2509fe",
|
||||
"reference": "93b7f4d01a2b7794374d53b7d5cf8e4b9d2509fe",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -4981,12 +4981,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/query.git",
|
||||
"reference": "efd571cd04963b91128fcdb1adb0b27c67417c32"
|
||||
"reference": "d40bf14fed0a5a92146d89cc6549518a2a559c8c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/query/zipball/efd571cd04963b91128fcdb1adb0b27c67417c32",
|
||||
"reference": "efd571cd04963b91128fcdb1adb0b27c67417c32",
|
||||
"url": "https://api.github.com/repos/utopia-php/query/zipball/d40bf14fed0a5a92146d89cc6549518a2a559c8c",
|
||||
"reference": "d40bf14fed0a5a92146d89cc6549518a2a559c8c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -4994,7 +4994,7 @@
|
||||
},
|
||||
"require-dev": {
|
||||
"laravel/pint": "*",
|
||||
"mongodb/mongodb": "^1.20",
|
||||
"mongodb/mongodb": "^2.0",
|
||||
"phpstan/phpstan": "*",
|
||||
"phpunit/phpunit": "^12.0"
|
||||
},
|
||||
@@ -5020,7 +5020,7 @@
|
||||
"issues": "https://github.com/utopia-php/query/issues",
|
||||
"source": "https://github.com/utopia-php/query/tree/feat-builder"
|
||||
},
|
||||
"time": "2026-03-26T14:39:58+00:00"
|
||||
"time": "2026-03-31T02:21:12+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/queue",
|
||||
|
||||
+3
-3
@@ -245,7 +245,7 @@ abstract class Action extends UtopiaAction
|
||||
? UtopiaResponse::MODEL_ATTRIBUTE_INTEGER
|
||||
: UtopiaResponse::MODEL_COLUMN_INTEGER,
|
||||
|
||||
ColumnType::Float->value => $isCollections
|
||||
ColumnType::Double->value => $isCollections
|
||||
? UtopiaResponse::MODEL_ATTRIBUTE_FLOAT
|
||||
: UtopiaResponse::MODEL_COLUMN_FLOAT,
|
||||
|
||||
@@ -553,9 +553,9 @@ abstract class Action extends UtopiaAction
|
||||
}
|
||||
|
||||
if ($attribute->getAttribute('format') === APP_DATABASE_ATTRIBUTE_INT_RANGE) {
|
||||
$validator = new Range($min, $max, ColumnType::Integer);
|
||||
$validator = new Range($min, $max, ColumnType::Integer->value);
|
||||
} else {
|
||||
$validator = new Range($min, $max, ColumnType::Float);
|
||||
$validator = new Range($min, $max, ColumnType::Double->value);
|
||||
|
||||
if (!is_null($default)) {
|
||||
$default = \floatval($default);
|
||||
|
||||
+2
-2
@@ -89,14 +89,14 @@ class Create extends Action
|
||||
throw new Exception($this->getInvalidValueException(), 'Minimum value must be lesser than maximum value');
|
||||
}
|
||||
|
||||
$validator = new Range($min, $max, ColumnType::Float->value);
|
||||
$validator = new Range($min, $max, ColumnType::Double->value);
|
||||
if (!\is_null($default) && !$validator->isValid($default)) {
|
||||
throw new Exception($this->getInvalidValueException(), $validator->getDescription());
|
||||
}
|
||||
|
||||
$attribute = $this->createAttribute($databaseId, $collectionId, new Document([
|
||||
'key' => $key,
|
||||
'type' => ColumnType::Float->value,
|
||||
'type' => ColumnType::Double->value,
|
||||
'size' => 0,
|
||||
'required' => $required,
|
||||
'default' => $default,
|
||||
|
||||
+1
-1
@@ -86,7 +86,7 @@ class Update extends Action
|
||||
dbForProject: $dbForProject,
|
||||
queueForEvents: $queueForEvents,
|
||||
authorization: $authorization,
|
||||
type: ColumnType::Float->value,
|
||||
type: ColumnType::Double->value,
|
||||
default: $default,
|
||||
required: $required,
|
||||
min: $min,
|
||||
|
||||
@@ -279,7 +279,9 @@ class Create extends Action
|
||||
array $attribute,
|
||||
): array {
|
||||
$key = $attribute['key'];
|
||||
$type = $attribute['type'];
|
||||
$type = $attribute['type'] === ColumnType::Float->value
|
||||
? ColumnType::Double->value
|
||||
: $attribute['type'];
|
||||
$size = $attribute['size'] ?? 0;
|
||||
$required = $attribute['required'] ?? false;
|
||||
$signed = $attribute['signed'] ?? true;
|
||||
|
||||
@@ -159,7 +159,7 @@ class Databases extends Action
|
||||
// Float/int/bool values may be converted to strings during serialization
|
||||
if ($default !== null) {
|
||||
$default = match ($type) {
|
||||
ColumnType::Float->value => \floatval($default),
|
||||
ColumnType::Double->value => \floatval($default),
|
||||
ColumnType::Integer->value => \intval($default),
|
||||
ColumnType::Boolean->value => \boolval($default),
|
||||
default => $default,
|
||||
|
||||
@@ -282,7 +282,7 @@ class Attributes extends Validator
|
||||
if (isset($attribute['min']) || isset($attribute['max'])) {
|
||||
$min = $attribute['min'] ?? -\PHP_FLOAT_MAX;
|
||||
$max = $attribute['max'] ?? \PHP_FLOAT_MAX;
|
||||
$rangeValidator = new Range($min, $max, ColumnType::Float->value);
|
||||
$rangeValidator = new Range($min, $max, ColumnType::Double->value);
|
||||
if (!$rangeValidator->isValid((float)$attribute['default'])) {
|
||||
$this->message = "Default value for float attribute '" . $attribute['key'] . "' must be between $min and $max";
|
||||
return false;
|
||||
|
||||
@@ -35,7 +35,7 @@ class Collection extends Model
|
||||
'example' => ['read("any")'],
|
||||
'array' => true
|
||||
])
|
||||
->addRule('$databaseId', [
|
||||
->addRule('databaseId', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Database ID.',
|
||||
'default' => '',
|
||||
|
||||
@@ -36,7 +36,7 @@ class Table extends Model
|
||||
'example' => ['read("any")'],
|
||||
'array' => true
|
||||
])
|
||||
->addRule('$databaseId', [
|
||||
->addRule('databaseId', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Database ID.',
|
||||
'default' => '',
|
||||
|
||||
Reference in New Issue
Block a user