Skip to content

Commit 67ade37

Browse files
author
James Cor
committed
so many types
1 parent 55ac3b4 commit 67ade37

File tree

4 files changed

+549
-4
lines changed

4 files changed

+549
-4
lines changed

sql/expression/comparison_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,3 +224,8 @@ func eval(t *testing.T, e sql.Expression, row sql.Row) interface{} {
224224
require.NoError(t, err)
225225
return v
226226
}
227+
228+
func TestValueComparison(t *testing.T) {
229+
require := require.New(t)
230+
231+
}

sql/types/number.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,13 +1131,24 @@ func ConvertValueToInt64(ctx *sql.Context, v sql.Value) (int64, error) {
11311131
return int64(v), nil
11321132
case sqltypes.Date:
11331133
v := values.ReadDate(v.Val)
1134-
return v.UTC().Unix(), nil
1134+
var res int64
1135+
res += int64(v.Year() * 10000)
1136+
res += int64(v.Month() * 100)
1137+
res += int64(v.Day())
1138+
return res, nil
11351139
case sqltypes.Time:
11361140
v := values.ReadInt64(v.Val)
11371141
return v, nil
11381142
case sqltypes.Datetime, sqltypes.Timestamp:
11391143
v := values.ReadDatetime(v.Val)
1140-
return v.UTC().Unix(), nil
1144+
var res int64
1145+
res += int64(v.Year() * 1_00_00_00_00_00)
1146+
res += int64(v.Month() * 1_00_00_00_00)
1147+
res += int64(v.Day() * 1_00_00_00)
1148+
res += int64(v.Hour() * 1_00_00)
1149+
res += int64(v.Minute() * 1_00)
1150+
res += int64(v.Second())
1151+
return res, nil
11411152
case sqltypes.Text, sqltypes.Blob:
11421153
var err error
11431154
if v.Val == nil {
@@ -1156,7 +1167,6 @@ func ConvertValueToInt64(ctx *sql.Context, v sql.Value) (int64, error) {
11561167
return 0, sql.ErrInvalidValue.New(v, v.Typ.String())
11571168
}
11581169
return i, err
1159-
// TODO: enum, set, json?
11601170
default:
11611171
return 0, sql.ErrInvalidBaseType.New(v.Typ.String(), "number")
11621172
}

0 commit comments

Comments
 (0)