Skip to content

Commit 493e957

Browse files
author
James Cor
committed
include other warnings
1 parent f5dd5e9 commit 493e957

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

enginetest/queries/script_queries.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,10 +1014,8 @@ var ScriptTests = []ScriptTest{
10141014
{"5.932887e7abc", uint64(5)},
10151015
{"a1a1", uint64(0)},
10161016
},
1017-
// TODO: Should be 19. Missing warnings for "Cast to unsigned converted negative integer to its positive
1018-
// complement" (1105) https://github.com/dolthub/dolt/issues/9840
1019-
ExpectedWarningsCount: 16,
1020-
ExpectedWarning: mysql.ERTruncatedWrongValue,
1017+
ExpectedWarningsCount: 19,
1018+
// Can't check multiple different warnings
10211019
},
10221020
{
10231021
Query: "select pk, cast(pk as decimal(12,3)) from test01",
@@ -1051,9 +1049,8 @@ var ScriptTests = []ScriptTest{
10511049
ExpectedWarningsCount: 0,
10521050
},
10531051

1054-
// TODO: these are not directly testing casting
1055-
// https://github.com/dolthub/dolt/issues/9739
10561052
{
1053+
// https://github.com/dolthub/dolt/issues/9739
10571054
Skip: true,
10581055
Dialect: "mysql",
10591056
Query: "select * from test01 where pk in (11)",

sql/expression/convert.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -413,13 +413,16 @@ func convertValue(ctx *sql.Context, val interface{}, castTo string, originType s
413413
return nil, err
414414
}
415415
// TODO: if truncation error and out of range, then throw 2's complement warning
416-
num, _, err := types.Uint64.Convert(ctx, value)
416+
num, inRange, err := types.Uint64.Convert(ctx, value)
417417
if err != nil {
418-
num, _, err = types.Int64.Convert(ctx, value)
419-
if err != nil {
420-
return types.Uint64.Zero(), nil
421-
}
422-
return uint64(num.(int64)), nil
418+
//num, inRange, err = types.Int64.Convert(ctx, value)
419+
//if err != nil {
420+
// return types.Uint64.Zero(), nil
421+
//}
422+
//num = uint64(num.(int64))
423+
}
424+
if !inRange {
425+
ctx.Warn(1105, "Cast to unsigned converted negative integer to its positive complement")
423426
}
424427
return num, nil
425428
case ConvertToYear:

0 commit comments

Comments
 (0)