Skip to content

Commit

Permalink
compare(): return error when error is encountered
Browse files Browse the repository at this point in the history
  • Loading branch information
mattnibs committed Feb 19, 2025
1 parent 79a220d commit 4c6b6e8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions runtime/sam/expr/function/compare.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ func (e *Compare) Call(_ super.Allocator, args []super.Value) super.Value {
}
nullsMax = args[2].Bool()
}
if args[0].IsError() {
return args[0]
}
if args[1].IsError() {
return args[1]
}
cmp := e.nullsMax
if !nullsMax {
cmp = e.nullsMin
Expand Down
4 changes: 4 additions & 0 deletions runtime/sam/expr/function/ztests/compare.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ input: |
{a: 2, b: "1"}
{a: null, b: 2}
{a: 0, b: 0.}
{a: 0}
{b: 0}
output: |
1
-1
1
0
error("missing")
error("missing")

0 comments on commit 4c6b6e8

Please sign in to comment.