Skip to content

Commit 7fce5df

Browse files
author
James Cor
committed
fix more queries
1 parent eeaf809 commit 7fce5df

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

enginetest/queries/function_queries.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1052,7 +1052,7 @@ var FunctionQueryTests = []QueryTest{
10521052
{
10531053
Query: `SELECT FLOOR(15728640/1024/1030)`,
10541054
Expected: []sql.Row{
1055-
{"14"},
1055+
{14},
10561056
},
10571057
},
10581058
{

enginetest/queries/queries.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,8 +1603,8 @@ SELECT * FROM cte WHERE d = 2;`,
16031603
{
16041604
Query: `SELECT column_0 FROM (values row(1+1,2+2), row(floor(1.5),concat("a","b"))) a order by 1`,
16051605
Expected: []sql.Row{
1606-
{1.0},
1607-
{2.0},
1606+
{1},
1607+
{2},
16081608
},
16091609
},
16101610
{
@@ -1882,8 +1882,8 @@ SELECT * FROM cte WHERE d = 2;`,
18821882
join (values row(2,4), row(1.0,"ab")) b on a.column_0 = b.column_0 and a.column_0 = b.column_0
18831883
order by 1`,
18841884
Expected: []sql.Row{
1885-
{1.0, "ab"},
1886-
{2.0, "4"},
1885+
{1, "ab"},
1886+
{2, "4"},
18871887
},
18881888
},
18891889
{
@@ -5509,11 +5509,11 @@ SELECT * FROM cte WHERE d = 2;`,
55095509
},
55105510
{
55115511
Query: "select ceil(i + 0.5) from mytable order by 1",
5512-
Expected: []sql.Row{{"2"}, {"3"}, {"4"}},
5512+
Expected: []sql.Row{{2}, {3}, {4}},
55135513
},
55145514
{
55155515
Query: "select floor(i + 0.5) from mytable order by 1",
5516-
Expected: []sql.Row{{"1"}, {"2"}, {"3"}},
5516+
Expected: []sql.Row{{1}, {2}, {3}},
55175517
},
55185518
{
55195519
Query: "select round(i + 0.55, 1) from mytable order by 1",

sql/expression/function/ceil_round_floor.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,18 +179,18 @@ func (f *Floor) Eval(ctx *sql.Context, row sql.Row) (interface{}, error) {
179179
ctx.Warn(mysql.ERTruncatedWrongValue, "%s", err.Error())
180180
}
181181
}
182-
// if it's number type and not float value, it does not need floor-ing
182+
183+
// if it's number type and not float value, it does not need ceil-ing
183184
switch num := child.(type) {
184185
case float32:
185-
return math.Floor(float64(num)), nil
186+
child = math.Floor(float64(num))
186187
case float64:
187-
return math.Floor(num), nil
188+
child = math.Floor(num)
188189
case decimal.Decimal:
189-
return num.Floor(), nil
190-
default:
191-
num, _, _ = f.Type().Convert(ctx, child)
192-
return num, nil
190+
child = num.Floor()
193191
}
192+
child, _, _ = f.Type().Convert(ctx, child)
193+
return child, nil
194194
}
195195

196196
// Round returns the number (x) with (d) requested decimal places.

0 commit comments

Comments
 (0)