Skip to content

Commit 04150db

Browse files
committed
fix if test
1 parent 85a753d commit 04150db

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

sql/expression/function/if_test.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,22 @@ func TestIf(t *testing.T) {
2929
expr sql.Expression
3030
row sql.Row
3131
expected interface{}
32+
type1 sql.Type
33+
type2 sql.Type
3234
}{
33-
{eq(lit(1, types.Int64), lit(1, types.Int64)), sql.Row{"a", "b"}, "a"},
34-
{eq(lit(1, types.Int64), lit(0, types.Int64)), sql.Row{"a", "b"}, "b"},
35-
{eq(lit(1, types.Int64), lit(1, types.Int64)), sql.Row{1, 2}, 1},
36-
{eq(lit(1, types.Int64), lit(0, types.Int64)), sql.Row{1, 2}, 2},
37-
{eq(lit(nil, types.Int64), lit(1, types.Int64)), sql.Row{"a", "b"}, "b"},
38-
{eq(lit(1, types.Int64), lit(1, types.Int64)), sql.Row{nil, "b"}, nil},
35+
{eq(lit(1, types.Int64), lit(1, types.Int64)), sql.Row{"a", "b"}, "a", types.Text, types.Text},
36+
{eq(lit(1, types.Int64), lit(0, types.Int64)), sql.Row{"a", "b"}, "b", types.Text, types.Text},
37+
{eq(lit(1, types.Int64), lit(1, types.Int64)), sql.Row{1, 2}, int64(1), types.Int64, types.Int64},
38+
{eq(lit(1, types.Int64), lit(0, types.Int64)), sql.Row{1, 2}, int64(2), types.Int64, types.Int64},
39+
{eq(lit(nil, types.Int64), lit(1, types.Int64)), sql.Row{"a", "b"}, "b", types.Text, types.Text},
40+
{eq(lit(1, types.Int64), lit(1, types.Int64)), sql.Row{nil, "b"}, nil, nil, types.Text},
3941
}
4042

4143
for _, tc := range testCases {
4244
f := NewIf(
4345
tc.expr,
44-
expression.NewGetField(0, types.LongText, "true", true),
45-
expression.NewGetField(1, types.LongText, "false", true),
46+
expression.NewGetField(0, tc.type1, "true", true),
47+
expression.NewGetField(1, tc.type2, "false", true),
4648
)
4749

4850
v, err := f.Eval(sql.NewEmptyContext(), tc.row)

0 commit comments

Comments
 (0)