diff --git a/app/init.php b/app/init.php index fd509297f6..d4bb38c5b4 100644 --- a/app/init.php +++ b/app/init.php @@ -181,7 +181,7 @@ if(!empty($user) || !empty($pass)) { */ Database::addFilter('casting', function($value) { - return json_encode(['value' => $value]); + return json_encode(['value' => $value], JSON_PRESERVE_ZERO_FRACTION); }, function($value) { if (is_null($value)) { diff --git a/app/workers/database.php b/app/workers/database.php index d95ce122d0..5fd3e16e25 100644 --- a/app/workers/database.php +++ b/app/workers/database.php @@ -71,6 +71,11 @@ class DatabaseV1 extends Worker $dbForConsole = $this->getConsoleDB(); $dbForProject = $this->getProjectDB($projectId); + /** + * Fetch attribute from the database, since with Resque float values are loosing informations. + */ + $attribute = $dbForProject->getDocument('attributes', $attribute->getId()); + $event = 'database.attributes.update'; $collectionId = $collection->getId(); $key = $attribute->getAttribute('key', ''); diff --git a/tests/e2e/Services/Database/DatabaseBase.php b/tests/e2e/Services/Database/DatabaseBase.php index 94e737ff37..640ab99361 100644 --- a/tests/e2e/Services/Database/DatabaseBase.php +++ b/tests/e2e/Services/Database/DatabaseBase.php @@ -1428,6 +1428,7 @@ trait DatabaseBase ]), [ 'key' => 'probability', 'required' => false, + 'default' => 0, 'min' => 0, 'max' => 1, ]);