本文整理汇总了Golang中github.com/pingcap/tidb/expression.Expression.Accept方法的典型用法代码示例。如果您正苦于以下问题:Golang Expression.Accept方法的具体用法?Golang Expression.Accept怎么用?Golang Expression.Accept使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/pingcap/tidb/expression.Expression
的用法示例。
在下文中一共展示了Expression.Accept方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestBase
func (s *testVisitorSuite) TestBase(c *C) {
val := expression.Value{Val: 1}
visitor := expression.NewIdentEvalVisitor()
var exp expression.Expression
exp = &expression.Between{Expr: val, Left: val, Right: val}
exp.Accept(visitor)
exp = expression.NewBinaryOperation(opcode.And, val, val)
exp.Accept(visitor)
exp, _ = expression.NewCall("avg", []expression.Expression{val}, true)
exp.Accept(visitor)
rows := [][]interface{}{{1}}
sq := newMockSubQuery(rows, []string{"a"})
exp = expression.NewCompareSubQuery(opcode.EQ, val, sq, true)
exp.Accept(visitor)
exp = &expression.Default{Name: "a"}
exp.Accept(visitor)
exp = expression.NewExistsSubQuery(sq)
exp.Accept(visitor)
when := &expression.WhenClause{Expr: val, Result: val}
exp = &expression.FunctionCase{
WhenClauses: []*expression.WhenClause{when},
Value: val,
ElseClause: val,
}
exp.Accept(visitor)
exp = &expression.FunctionCast{Expr: val, Tp: types.NewFieldType(mysql.TypeLong), FunctionType: expression.ConvertFunction}
exp.Accept(visitor)
exp = &expression.FunctionConvert{Expr: val, Charset: "utf8"}
exp.Accept(visitor)
exp = &expression.FunctionSubstring{StrExpr: expression.Value{Val: "string"}, Pos: expression.Value{Val: 0}, Len: val}
exp.Accept(visitor)
exp = &expression.IsNull{Expr: val}
exp.Accept(visitor)
exp = &expression.IsTruth{Expr: val}
exp.Accept(visitor)
exp = &expression.ParamMarker{Expr: val}
exp.Accept(visitor)
exp = &expression.PatternIn{Expr: val, List: []expression.Expression{val}}
exp.Accept(visitor)
exp = &expression.PatternLike{Expr: val, Pattern: val}
exp.Accept(visitor)
exp = &expression.PatternRegexp{Expr: val, Pattern: val}
exp.Accept(visitor)
exp = &expression.PExpr{Expr: val}
exp.Accept(visitor)
exp = &expression.Position{Name: "a"}
exp.Accept(visitor)
exp = &expression.Row{Values: []expression.Expression{val}}
exp.Accept(visitor)
exp = &expression.UnaryOperation{V: val}
exp.Accept(visitor)
exp = &expression.Values{CIStr: model.NewCIStr("a")}
exp.Accept(visitor)
exp = &expression.Variable{Name: "a"}
exp.Accept(visitor)
}