edgedb icon indicating copy to clipboard operation
edgedb copied to clipboard

Slicing behaves incorrectly on NULL empty sets

Open msullivan opened this issue 3 years ago • 1 comments

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.

msullivan avatar Sep 07 '22 19:09 msullivan

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.

msullivan avatar Sep 08 '22 21:09 msullivan