Skip to content

Handling of "undefined" input to negate operator is inconsistent? #99

@tomklapiscak

Description

@tomklapiscak

JSONata, as a query system should be tolerant to finding ‘nothing’ as a routine thing. This is reflected by the fact that passing the undefined value (the Javascript value used to represent 'nothing' here) to any operator or function does not raise an error, instead just itself returning undefined.

For instance:
Where the path x is not on the context:
x + 1 => undefined (no error is raised)

(To my knowledge, the only meaningful exception to this behaviour is $exists(undefined) => false, but there may be others).

This behaviour is not observed by the negate operator. E.g.
-x raises an error (Cannot negate a non-numeric value: undefined).

Is this another deliberate exception to this behaviour, or is this a bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions