edgedb
edgedb copied to clipboard
Slicing behaves incorrectly on NULL empty sets
Another instance of a classic edgedb bug.
Slicing is a regular (non-optional) operation, and so empty set inputs should result in an empty set output, like such:
edgedb> select [1,2,3][1:<int64>{}];
[]
But empty sets that get represented as NULL produce output as if the argument was omitted:
edgedb> select [1,2,3][1:<optional int64>$0];
Parameter <int64>$0 (Ctrl+D for empty set `{}`):
[[2, 3]]
The root of the issue is that all slicing (missing arguments or not) is done by calling a _slice function, and we represent missing bounds as NULL.
And json slicing behaves incorrectly on NULL subjects:
edgedb> select (<optional json>$0)[0:];
Parameter <json>$0 (Ctrl+D for empty set `{}`):
edgedb error: InvalidValueError: cannot slice JSON UNKNOWN
Hint: Slicing is only available for JSON arrays and strings.