@@ -1012,23 +1012,23 @@ func (b *indexScanRangeBuilder) rangeBuildDefaultLeaf(bb *sql.MySQLIndexBuilder,
10121012 name := f .normString ()
10131013 switch f .Op () {
10141014 case sql .IndexScanOpEq :
1015- bb .Equals (b .ctx , name , f .gf . Type () , f .litValue )
1015+ bb .Equals (b .ctx , name , f .litType , f .litValue )
10161016 case sql .IndexScanOpNotEq :
1017- bb .NotEquals (b .ctx , name , f .gf . Type () , f .litValue )
1017+ bb .NotEquals (b .ctx , name , f .litType , f .litValue )
10181018 case sql .IndexScanOpInSet :
1019- bb .Equals (b .ctx , name , f .gf . Type () , f .setValues ... )
1019+ bb .Equals (b .ctx , name , f .litType , f .setValues ... )
10201020 case sql .IndexScanOpNotInSet :
10211021 for _ , v := range f .setValues {
1022- bb .NotEquals (b .ctx , name , f .gf . Type () , v )
1022+ bb .NotEquals (b .ctx , name , f .litType , v )
10231023 }
10241024 case sql .IndexScanOpGt :
1025- bb .GreaterThan (b .ctx , name , f .gf . Type () , f .litValue )
1025+ bb .GreaterThan (b .ctx , name , f .litType , f .litValue )
10261026 case sql .IndexScanOpGte :
1027- bb .GreaterOrEqual (b .ctx , name , f .gf . Type () , f .litValue )
1027+ bb .GreaterOrEqual (b .ctx , name , f .litType , f .litValue )
10281028 case sql .IndexScanOpLt :
1029- bb .LessThan (b .ctx , name , f .gf . Type () , f .litValue )
1029+ bb .LessThan (b .ctx , name , f .litType , f .litValue )
10301030 case sql .IndexScanOpLte :
1031- bb .LessOrEqual (b .ctx , name , f .gf . Type () , f .litValue )
1031+ bb .LessOrEqual (b .ctx , name , f .litType , f .litValue )
10321032 case sql .IndexScanOpIsNotNull :
10331033 bb .IsNotNull (b .ctx , name )
10341034 case sql .IndexScanOpIsNull :
@@ -1037,7 +1037,7 @@ func (b *indexScanRangeBuilder) rangeBuildDefaultLeaf(bb *sql.MySQLIndexBuilder,
10371037 if f .litValue == nil {
10381038 bb .IsNull (b .ctx , name )
10391039 } else {
1040- bb .Equals (b .ctx , name , f .gf . Type () , f .litValue )
1040+ bb .Equals (b .ctx , name , f .litType , f .litValue )
10411041 }
10421042 default :
10431043 panic (fmt .Sprintf ("unknown IndexScanOp: %d" , f .Op ()))
@@ -1070,6 +1070,7 @@ type indexFilter interface {
10701070
10711071type iScanLeaf struct {
10721072 litValue interface {}
1073+ litType sql.Type
10731074 gf * expression.GetField
10741075 underlying string
10751076 fulltextIndex string
@@ -1439,7 +1440,14 @@ func newLeaf(ctx *sql.Context, id indexScanId, e sql.Expression, underlying stri
14391440 return nil , false
14401441 }
14411442
1442- return & iScanLeaf {id : id , gf : gf , op : op , litValue : value , underlying : underlying }, true
1443+ return & iScanLeaf {
1444+ id : id ,
1445+ gf : gf ,
1446+ op : op ,
1447+ litValue : value ,
1448+ litType : right .Type (),
1449+ underlying : underlying ,
1450+ }, true
14431451}
14441452
14451453// IndexLeafChildren handles the struct types that may be found on a leaf node while creating indexes.
0 commit comments