Skip to content

Commit 36f983d

Browse files
committed
fix tests expectations
1 parent 62f3001 commit 36f983d

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

enginetest/queries/script_queries.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ var ScriptTests = []ScriptTest{
255255
},
256256
ExpectedWarning: mysql.ERTruncatedWrongValue,
257257
ExpectedWarningsCount: 1,
258-
ExpectedWarningMessageSubstring: "Truncated incorrect DOUBLE value",
258+
ExpectedWarningMessageSubstring: fmt.Sprintf(sql.ErrTruncatedIncorrect.Message, types.Float64.String(), "123abc"),
259259
},
260260
{
261261
Query: "SELECT TRUNCATE('1.5abc',1)",
@@ -264,7 +264,7 @@ var ScriptTests = []ScriptTest{
264264
},
265265
ExpectedWarning: mysql.ERTruncatedWrongValue,
266266
ExpectedWarningsCount: 1,
267-
ExpectedWarningMessageSubstring: "Truncated incorrect DOUBLE value",
267+
ExpectedWarningMessageSubstring: fmt.Sprintf(sql.ErrTruncatedIncorrect.Message, types.Float64.String(), "1.5abc"),
268268
},
269269
{
270270
Query: "SELECT TRUNCATE('999xyz',2)",
@@ -273,7 +273,7 @@ var ScriptTests = []ScriptTest{
273273
},
274274
ExpectedWarning: mysql.ERTruncatedWrongValue,
275275
ExpectedWarningsCount: 1,
276-
ExpectedWarningMessageSubstring: "Truncated incorrect DOUBLE value",
276+
ExpectedWarningMessageSubstring: fmt.Sprintf(sql.ErrTruncatedIncorrect.Message, types.Float64.String(), "999xyz"),
277277
},
278278
{
279279
Query: "SELECT TRUNCATE(1.223,'1.5abc')",
@@ -282,7 +282,7 @@ var ScriptTests = []ScriptTest{
282282
},
283283
ExpectedWarning: mysql.ERTruncatedWrongValue,
284284
ExpectedWarningsCount: 2, // Both input and precision conversions generate warnings
285-
ExpectedWarningMessageSubstring: "Truncated incorrect int value",
285+
ExpectedWarningMessageSubstring: fmt.Sprintf(sql.ErrTruncatedIncorrect.Message, types.Int32.String(), "1.5abc"),
286286
},
287287
{
288288
Query: "SELECT TRUNCATE(1.223,'0.5')",
@@ -291,7 +291,7 @@ var ScriptTests = []ScriptTest{
291291
},
292292
ExpectedWarning: mysql.ERTruncatedWrongValue,
293293
ExpectedWarningsCount: 2, // Both input and precision conversions generate warnings
294-
ExpectedWarningMessageSubstring: "Truncated incorrect int value",
294+
ExpectedWarningMessageSubstring: fmt.Sprintf(sql.ErrTruncatedIncorrect.Message, types.Int32.String(), "0.5"),
295295
},
296296
{
297297
Query: "SELECT TRUNCATE(1.223,'2.7')",
@@ -300,7 +300,7 @@ var ScriptTests = []ScriptTest{
300300
},
301301
ExpectedWarning: mysql.ERTruncatedWrongValue,
302302
ExpectedWarningsCount: 2, // Both input and precision conversions generate warnings
303-
ExpectedWarningMessageSubstring: "Truncated incorrect int value",
303+
ExpectedWarningMessageSubstring: fmt.Sprintf(sql.ErrTruncatedIncorrect.Message, types.Int32.String(), "2.7"),
304304
},
305305
{
306306
Query: "SELECT TRUNCATE(1.223,'invalid_precision')",
@@ -309,7 +309,7 @@ var ScriptTests = []ScriptTest{
309309
},
310310
ExpectedWarning: mysql.ERTruncatedWrongValue,
311311
ExpectedWarningsCount: 2, // Both input and precision conversions generate warnings
312-
ExpectedWarningMessageSubstring: "Truncated incorrect int value",
312+
ExpectedWarningMessageSubstring: fmt.Sprintf(sql.ErrTruncatedIncorrect.Message, types.Int32.String(), "invalid_precision"),
313313
},
314314
{
315315
Query: "SELECT TRUNCATE()",

sql/expression/function/truncate.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func (t *Truncate) Eval(ctx *sql.Context, row sql.Row) (interface{}, error) {
6969
// Convert to DOUBLE first to match MySQL warning behavior
7070
val, _, err = types.Float64.Convert(ctx, val)
7171
if err != nil && sql.ErrTruncatedIncorrect.Is(err) {
72-
ctx.Warn(mysql.ERTruncatedWrongValue, "Truncated incorrect DOUBLE value: '%s'", val)
72+
ctx.Warn(mysql.ERTruncatedWrongValue, "%s", err.Error())
7373
}
7474

7575
// Then convert to decimal for truncation logic
@@ -159,7 +159,7 @@ func (t *Truncate) Type() sql.Type {
159159
}
160160

161161
// CollationCoercibility implements the interface sql.CollationCoercible.
162-
func (*Truncate) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID, coercibility byte) {
162+
func (*Truncate) CollationCoercibility(*sql.Context) (collation sql.CollationID, coercibility byte) {
163163
return sql.Collation_binary, 5
164164
}
165165

0 commit comments

Comments
 (0)