Skip to content

Condition on 0.0 returns false #93

@ashokadewit

Description

@ashokadewit

Value:

[
    'orders' => [
        ['price' => 0.0],
        ['price' => 1.0],
        ['price' => 2.0]
    ]
]

Expression: orders[?price].price

Expected result (result in the Javascript version of JMESPath) :

[0.0, 1.0, 2.0]

Actual result:

[1.0, 2.0]

The cause is in Utils.php, there are special cases for 0 and '0' but not for 0.0.

    public static function isTruthy($value)
    {
        if (!$value) {
            return $value === 0 || $value === '0';
        } elseif ($value instanceof \stdClass) {
            return (bool) get_object_vars($value);
        } else {
            return true;
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions