Skip to content

Commit a1faa65

Browse files
committed
address feedback comments
1 parent 113ccfd commit a1faa65

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

enginetest/queries/script_queries.go

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,7 +1032,6 @@ FROM task_instance INNER JOIN job ON job.id = task_instance.queued_by_job_id INN
10321032
// Related Issues:
10331033
// https://github.com/dolthub/dolt/issues/9733
10341034
// https://github.com/dolthub/dolt/issues/9739
1035-
// https://github.com/dolthub/dolt/issues/9936
10361035
Dialect: "mysql",
10371036
Name: "strings cast to numbers",
10381037
SetUpScript: []string{
@@ -1043,9 +1042,6 @@ FROM task_instance INNER JOIN job ON job.id = task_instance.queued_by_job_id INN
10431042
('3. 12 4'),('5.932887e+07'),('5.932887e+07abc'),('5.932887e7'),('5.932887e7abc');`,
10441043
"create table test02(pk int primary key);",
10451044
"insert into test02 values(11),(12),(13),(14),(15);",
1046-
"create table t0(c0 varchar(500))",
1047-
"insert into t0(c0) values (77367106)",
1048-
"create index i0 using hash on t0(c0) invisible",
10491045
},
10501046
Assertions: []ScriptTestAssertion{
10511047
{
@@ -1232,43 +1228,46 @@ FROM task_instance INNER JOIN job ON job.id = task_instance.queued_by_job_id INN
12321228
ExpectedWarningsCount: 1,
12331229
ExpectedWarning: mysql.ERTruncatedWrongValue,
12341230
},
1231+
},
1232+
},
1233+
{
1234+
// https://github.com/dolthub/dolt/issues/9936
1235+
Name: "invisible hash index with different key types",
1236+
SetUpScript: []string{
1237+
"create table t0(c0 varchar(500))",
1238+
"insert into t0(c0) values (77367106)",
1239+
"create index i0 using hash on t0(c0) invisible",
1240+
},
1241+
Assertions: []ScriptTestAssertion{
12351242
{
1236-
// https://github.com/dolthub/dolt/issues/9936
12371243
Query: "select c0 from t0 where 1630944823 >= t0.c0",
12381244
Expected: []sql.Row{{"77367106"}},
12391245
},
12401246
{
1241-
// https://github.com/dolthub/dolt/issues/9936
12421247
Query: "select c0 from t0 where 1630944823 <= t0.c0",
12431248
Expected: []sql.Row{},
12441249
},
12451250
{
1246-
// https://github.com/dolthub/dolt/issues/9936
12471251
Query: "select c0 from t0 where '1630944823' >= t0.c0",
12481252
Expected: []sql.Row{},
12491253
},
12501254
{
1251-
// https://github.com/dolthub/dolt/issues/9936
12521255
Query: "select c0 from t0 where '1630944823' <= t0.c0",
12531256
Expected: []sql.Row{{"77367106"}},
12541257
},
12551258
{
1256-
// https://github.com/dolthub/dolt/issues/9936
12571259
Query: "select c0 from t0 where 1630944823.2 >= t0.c0",
12581260
Expected: []sql.Row{{"77367106"}},
12591261
},
12601262
{
1261-
// https://github.com/dolthub/dolt/issues/9936
12621263
Query: "select c0 from t0 where 1630944823.2 <= t0.c0",
12631264
Expected: []sql.Row{},
12641265
},
12651266
{
1266-
// https://github.com/dolthub/dolt/issues/9936
12671267
Query: "select c0 from t0 where '1630944823.2' >= t0.c0",
12681268
Expected: []sql.Row{},
12691269
},
12701270
{
1271-
// https://github.com/dolthub/dolt/issues/9936
12721271
Query: "select c0 from t0 where '1630944823.2' <= t0.c0",
12731272
Expected: []sql.Row{{"77367106"}},
12741273
},

sql/index_builder.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,8 @@ func (b *MySQLIndexBuilder) GreaterThan(ctx *Context, colExpr string, keyType Ty
224224
return b
225225
}
226226

227-
func isValidKeyType(colType Type, keyType Type) bool {
227+
// isConvertibleKeyType checks if the key can be converted into the column type
228+
func isConvertibleKeyType(colType Type, keyType Type) bool {
228229
if IsStringType(colType) {
229230
return !(IsNumberType(keyType) || IsDecimalType(keyType))
230231
}
@@ -237,7 +238,7 @@ func (b *MySQLIndexBuilder) convertKey(ctx *Context, colType Type, keyType Type,
237238
if et, ok := colType.(ExtendedType); ok {
238239
return et.ConvertToType(ctx, keyType.(ExtendedType), key)
239240
} else {
240-
if !isValidKeyType(colType, keyType) {
241+
if !isConvertibleKeyType(colType, keyType) {
241242
return nil, ErrInvalidValueType.New(key, colType)
242243
}
243244
k, _, err := colType.Convert(ctx, key)

0 commit comments

Comments
 (0)