Skip to content

Commit c5d4cc2

Browse files
committed
use max datetime precision for comparisons
1 parent 4244a2a commit c5d4cc2

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

sql/expression/comparison.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,13 +222,15 @@ func (c *comparison) castLeftAndRight(ctx *sql.Context, left, right interface{})
222222
}
223223

224224
if types.IsTime(leftType) || types.IsTime(rightType) {
225-
// TODO: We need to set to actual Datetime type
226-
l, r, err := convertLeftAndRight(ctx, left, right, ConvertToDatetime)
225+
l, _, err := types.DatetimeMaxPrecision.Convert(ctx, left)
227226
if err != nil {
228227
return nil, nil, nil, err
229228
}
230-
231-
return l, r, types.DatetimeDefaultPrecision, nil
229+
r, _, err := types.DatetimeMaxPrecision.Convert(ctx, right)
230+
if err != nil {
231+
return nil, nil, nil, err
232+
}
233+
return l, r, types.DatetimeMaxPrecision, nil
232234
}
233235

234236
// Rely on types.JSON.Compare to handle JSON comparisons

0 commit comments

Comments
 (0)