From 29f7b570c4eaf20e1abbb12b4acd7cd7dd3e656d Mon Sep 17 00:00:00 2001 From: Jian Zhang Date: Thu, 7 Sep 2017 16:46:18 +0800 Subject: [PATCH] expression: rewrite "fieldTp2EvalTp()" to use "mysql.TypeXXX" instead of "TypeClass" (#4467) --- expression/builtin.go | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/expression/builtin.go b/expression/builtin.go index 2da20263c8..b6855cb339 100644 --- a/expression/builtin.go +++ b/expression/builtin.go @@ -46,24 +46,22 @@ const ( ) func fieldTp2EvalTp(tp *types.FieldType) evalTp { - switch tp.ToClass() { - case types.ClassInt: + switch tp.Tp { + case mysql.TypeTiny, mysql.TypeShort, mysql.TypeInt24, mysql.TypeLong, mysql.TypeLonglong, + mysql.TypeBit, mysql.TypeYear: return tpInt - case types.ClassReal: + case mysql.TypeFloat, mysql.TypeDouble: return tpReal - case types.ClassDecimal: + case mysql.TypeNewDecimal: return tpDecimal - case types.ClassString: - switch tp.Tp { - case mysql.TypeDate, mysql.TypeDatetime: - return tpDatetime - case mysql.TypeTimestamp: - return tpTimestamp - case mysql.TypeDuration: - return tpDuration - case mysql.TypeJSON: - return tpJSON - } + case mysql.TypeDate, mysql.TypeDatetime: + return tpDatetime + case mysql.TypeTimestamp: + return tpTimestamp + case mysql.TypeDuration: + return tpDuration + case mysql.TypeJSON: + return tpJSON } return tpString }