1
0
Fork 0
mirror of synced 2024-06-02 10:54:44 +12:00

fix: convert default value to float on attribute creation

This commit is contained in:
Torsten Dittmann 2021-12-14 22:01:58 +01:00 committed by GitHub
parent 8f583cc063
commit 5463258df9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1045,7 +1045,7 @@ App::post('/v1/database/collections/:collectionId/attributes/float')
->inject('database')
->inject('audits')
->inject('usage')
->action(function ($collectionId, $attributeId, $required, $min, $max, $default, $array, $response, $dbForInternal, $dbForExternal,$database, $audits, $usage) {
->action(function ($collectionId, $attributeId, $required, $min, $max, $default, $array, $response, $dbForInternal, $dbForExternal, $database, $audits, $usage) {
/** @var Appwrite\Utopia\Response $response */
/** @var Utopia\Database\Database $dbForInternal*/
/** @var Utopia\Database\Database $dbForExternal*/
@ -1060,6 +1060,11 @@ App::post('/v1/database/collections/:collectionId/attributes/float')
if ($min > $max) {
throw new Exception('Minimum value must be lesser than maximum value', 400);
}
// Ensure default value is a float
if (!is_null($default)) {
$default = \floatval($default);
}
$validator = new Range($min, $max, Database::VAR_FLOAT);