Skip to content

Commit aef177a

Browse files
author
James Cor
committed
fix remaining truncation errors
1 parent c2abf58 commit aef177a

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

sql/expression/in.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,11 @@ func (in *InTuple) Eval(ctx *sql.Context, row sql.Row) (interface{}, error) {
150150

151151
lv, _, lErr := cmpType.Convert(ctx, leftVal)
152152
if lErr != nil {
153-
if !sql.ErrTruncatedIncorrect.Is(lErr) {
154-
return nil, lErr
153+
if sql.ErrTruncatedIncorrect.Is(lErr) {
154+
ctx.Warn(mysql.ERTruncatedWrongValue, "%s", lErr.Error())
155+
} else {
156+
lv = cmpType.Zero()
155157
}
156-
ctx.Warn(mysql.ERTruncatedWrongValue, "%s", lErr.Error())
157158
}
158159

159160
for _, rVal := range rVals {
@@ -162,14 +163,15 @@ func (in *InTuple) Eval(ctx *sql.Context, row sql.Row) (interface{}, error) {
162163
}
163164
rv, _, rErr := cmpType.Convert(ctx, rVal)
164165
if rErr != nil {
165-
if !sql.ErrTruncatedIncorrect.Is(rErr) {
166-
return nil, rErr
166+
if sql.ErrTruncatedIncorrect.Is(rErr) {
167+
ctx.Warn(mysql.ERTruncatedWrongValue, "%s", rErr.Error())
168+
} else {
169+
rv = cmpType.Zero()
167170
}
168-
ctx.Warn(mysql.ERTruncatedWrongValue, "%s", rErr.Error())
169171
}
170172
cmp, cErr := cmpType.Compare(ctx, lv, rv)
171173
if cErr != nil {
172-
return nil, cErr
174+
continue
173175
}
174176
if cmp == 0 {
175177
return true, nil

sql/expression/in_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ func TestInTuple(t *testing.T) {
178178
expression.NewLiteral("hi", types.TinyText),
179179
expression.NewLiteral("bye", types.TinyText),
180180
),
181-
err: types.ErrConvertingToTime,
181+
err: nil,
182182
row: nil,
183183
result: false,
184184
}}

0 commit comments

Comments
 (0)