Skip to content

Commit

Permalink
Merge pull request #347 from dolthub/daylon/injected-statement
Browse files Browse the repository at this point in the history
Added InjectedStatement
  • Loading branch information
Hydrocharged authored May 21, 2024
2 parents ff7bd63 + ae2979f commit e778edc
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions go/vt/sqlparser/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -7490,16 +7490,16 @@ func (node *SrsAttribute) Format(buf *TrackedBuffer) {
buf.Myprintf("description '%s'", node.Description)
}

// InjectableExpression is an expression that can accept a set of analyzed/resolved children. Used within InjectedExpr.
type InjectableExpression interface {
// Injectable is an expression that can accept a set of analyzed/resolved children. Used within InjectedExpr.
type Injectable interface {
WithResolvedChildren(children []any) (any, error)
}

// InjectedExpr allows bypassing AST analysis. This is used by projects that rely on Vitess, but may not implement
// MySQL's dialect.
type InjectedExpr struct {
Expression InjectableExpression
Children []Expr
Expression Injectable
Children Exprs
}

var _ Expr = InjectedExpr{}
Expand All @@ -7520,3 +7520,24 @@ func (d InjectedExpr) Format(buf *TrackedBuffer) {
buf.WriteString("InjectedExpr")
}
}

// InjectedStatement allows bypassing AST analysis. This is used by projects that rely on Vitess, but may not implement
// MySQL's dialect.
type InjectedStatement struct {
Statement Injectable
Children Exprs
}

var _ Statement = InjectedStatement{}

// iStatement implements the Statement interface.
func (d InjectedStatement) iStatement() {}

// Format implements the Statement interface.
func (d InjectedStatement) Format(buf *TrackedBuffer) {
if stringer, ok := d.Statement.(fmt.Stringer); ok {
buf.WriteString(stringer.String())
} else {
buf.WriteString("InjectedStatement")
}
}

0 comments on commit e778edc

Please sign in to comment.