func (v *typeInferrer) convertValueToColumnTypeIfNeeded(x *ast.PatternInExpr) {
	if cn, ok := x.Expr.(*ast.ColumnNameExpr); ok && cn.Refer != nil {
		ft := cn.Refer.Column.FieldType
		for _, expr := range x.List {
			if valueExpr, ok := expr.(*ast.ValueExpr); ok {
				newDatum, err := valueExpr.Datum.ConvertTo(v.sc, &ft)
				if err != nil {
					v.err = errors.Trace(err)
				}
				cmp, err := newDatum.CompareDatum(v.sc, valueExpr.Datum)
				if err != nil {
					v.err = errors.Trace(err)
				}
				if cmp != 0 {
					// The value will never match the column, do not set newDatum.
					continue
				}
				valueExpr.SetDatum(newDatum)
			}
		}
		if v.err != nil {
			// TODO: Errors should be handled differently according to query context.
			log.Errorf("inferor type for pattern in error %v", v.err)
			v.err = nil
		}
	}
}
// ConvertValueToColumnTypeIfNeeded checks if the expr in PatternInExpr is column name,
// and casts function to the items in the list.
ConvertValueToColumnTypeIfNeeded checks if the expr in PatternInExpr is column name,
and casts function to the items in the list.
// ConvertValueToColumnTypeIfNeeded checks if the expr in PatternInExpr is column name // and casts function to the items in the list .
func (v *typeInferrer) convertValueToColumnTypeIfNeeded(x *ast.PatternInExpr) {
	if cn, ok := x.Expr.(*ast.ColumnNameExpr); ok && cn.Refer != nil {
		ft := cn.Refer.Column.FieldType
		for _, expr := range x.List {
			if valueExpr, ok := expr.(*ast.ValueExpr); ok {
				newDatum, err := valueExpr.Datum.ConvertTo(v.sc, &ft)
				if err != nil {
					v.err = errors.Trace(err)
				}
				cmp, err := newDatum.CompareDatum(v.sc, valueExpr.Datum)
				if err != nil {
					v.err = errors.Trace(err)
				}
				if cmp != 0 {
					continue
				}
				valueExpr.SetDatum(newDatum)
			}
		}
		if v.err != nil {
			log.Errorf("inferor type for pattern in error %v", v.err)
			v.err = nil
		}
	}
}
func ( v * typeInferrer ) convertValueToColumnTypeIfNeeded ( x * ast . PatternInExpr ) { if cn , ok := x . Expr . ( * ast . ColumnNameExpr ) ; ok && cn . Refer != nil { ft := cn . Refer . Column . FieldType for _ , expr := range x . List { if valueExpr , ok := expr . ( * ast . ValueExpr ) ; ok { newDatum , err := valueExpr . Datum . ConvertTo ( v . sc , & ft ) if err != nil { v . err = errors . Trace ( err ) } cmp , err := newDatum . CompareDatum ( v . sc , valueExpr . Datum ) if err != nil { v . err = errors . Trace ( err ) } if cmp != 0 { continue } valueExpr . SetDatum ( newDatum ) } } if v . err != nil { log . Errorf ( " " , v . err ) v . err = nil } } }
ConvertValueToColumnTypeIfNeeded checks if the expr in PatternInExpr is column name,
and casts function to the items in the list.
ConvertValueToColumnTypeIfNeeded checks if the expr in PatternInExpr is column name and casts function to the items in the list .
// The value will never match the column, do not set newDatum. // TODO: Errors should be handled differently according to query context.