1
0
Fork 0
mirror of synced 2024-06-03 03:14:50 +12:00

Merge pull request #2498 from appwrite/feat-database-indexing-float-attribute

fix: convert default value to float on attribute creation
This commit is contained in:
Torsten Dittmann 2021-12-15 10:37:09 +01:00 committed by GitHub
commit 8a890a05e5
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);