-
Notifications
You must be signed in to change notification settings - Fork 256
Closed
Description
I would like someone to confirm whether the following behaviour is expected. Given:
{
"a": [
{"b": 1, "c": [1, 2, 3], "d": "foo"},
{"b": 2, "d": "bar"},
{"c": [0]}
]
}
a.exists(x, x.b == 1)
returnstrue
a.exists(x, x.b == 3 )
returns this error:failed to evaluate: no such key: b
Is this asymmetry expected? It seems that exists is positively safe but negatively unsafe, which feels weird. I would expect the evaluation to fail in both cases. For what it's worth, that is indeed what happens with filter
. You can check the example online here.
At first I thought that in the affirmative case the computation was being short-circuited after evaluating the first (matching) element but that is not the case. You can confirm by rearranging the array; the order does not matter.
Originally posted here:
Metadata
Metadata
Assignees
Labels
No labels