Switch inside FLOWR produces wrong results
ingomueller-net opened this issue · 1 comments
ingomueller-net commented
Consider the following query:
for $v in (1 to 10)
return
{"v": $v, "switch":
switch (true)
case (4 > $v) return "foo"
case (6 > $v) return "bar"
default return "baz"}
Rumble currently produces the following result:
rumble$ for $v in (1 to 10)
> return
> {"v": $v, "switch":
> switch (true)
> case (4 > $v) return "foo"
> case (6 > $v) return "bar"
> default return "baz"}
>>>
>>>
{ "v" : 1, "switch" : "foo" }
{ "v" : 2, "switch" : "foo" }
{ "v" : 3, "switch" : "foo" }
{ "v" : 4, "switch" : "bar" }
{ "v" : 5, "switch" : "bar" }
{ "v" : 6, "switch" : "bar" }
{ "v" : 7, "switch" : "bar" }
{ "v" : 8, "switch" : "bar" }
{ "v" : 9, "switch" : "bar" }
{ "v" : 10, "switch" : "bar" }
Note that the last five objects should have "baz"
as their switch
value. This must have to do with the state of the FLOWR expression: if the range starts at a different value, the default
case is used correctly:
rumble$ for $v in (6 to 10)
> return
> {"v": $v, "switch":
> switch (true)
> case (4 > $v) return "foo"
> case (6 > $v) return "bar"
> default return "baz"}
>>>
>>>
{ "v" : 6, "switch" : "baz" }
{ "v" : 7, "switch" : "baz" }
{ "v" : 8, "switch" : "baz" }
{ "v" : 9, "switch" : "baz" }
{ "v" : 10, "switch" : "baz" }
ghislainfourny commented
This is now fixed in the master. Thanks, @ingomueller-net