Skip to content

Commit

Permalink
refactor: update sqlparser package with new interfaces
Browse files Browse the repository at this point in the history
Signed-off-by: Andres Taylor <andres@planetscale.com>
  • Loading branch information
systay committed Jan 10, 2025
1 parent c1cbae5 commit 148c41b
Show file tree
Hide file tree
Showing 14 changed files with 8,421 additions and 8,323 deletions.
54 changes: 38 additions & 16 deletions go/vt/sqlparser/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,26 +57,45 @@ type (
OrderAndLimit interface {
AddOrder(*Order)
SetLimit(*Limit)
GetOrderBy() OrderBy
SetOrderBy(OrderBy)
GetLimit() *Limit
}

TableSubquery interface {
iTableSubquery()

InsertRows
Statement
OrderAndLimit
Commented
ColumnResults
Withable
}

ColumnResults interface {
GetColumnCount() int
GetColumns() SelectExprs
}

Withable interface {
SetWith(with *With)
}

// SelectStatement any SELECT statement.
SelectStatement interface {
Statement
InsertRows
OrderAndLimit
Commented
ColumnResults
Withable
iSelectStatement()
GetLock() Lock
SetLock(lock Lock)
SetInto(into *SelectInto)
SetWith(with *With)
MakeDistinct()
GetColumnCount() int
GetColumns() SelectExprs
Commented
IsDistinct() bool
GetOrderBy() OrderBy
SetOrderBy(OrderBy)
GetLimit() *Limit
}

// DDLStatement represents any DDL Statement
Expand Down Expand Up @@ -161,7 +180,7 @@ type (
CommonTableExpr struct {
ID IdentifierCS
Columns Columns
Subquery SelectStatement
Subquery TableSubquery
}
// ChangeColumn is used to change the column definition, can also rename the column in alter table command
ChangeColumn struct {
Expand Down Expand Up @@ -303,8 +322,8 @@ type (
// Union represents a UNION statement.
Union struct {
With *With
Left SelectStatement
Right SelectStatement
Left TableSubquery
Right TableSubquery
Distinct bool
OrderBy OrderBy
Limit *Limit
Expand Down Expand Up @@ -543,7 +562,7 @@ type (
Definer *Definer
Security string
Columns Columns
Select SelectStatement
Select TableSubquery
CheckOption string
IsReplace bool
Comments *ParsedComments
Expand All @@ -556,7 +575,7 @@ type (
Definer *Definer
Security string
Columns Columns
Select SelectStatement
Select TableSubquery
CheckOption string
Comments *ParsedComments
}
Expand Down Expand Up @@ -752,8 +771,10 @@ func (*Analyze) iStatement() {}
func (*OtherAdmin) iStatement() {}
func (*CommentOnly) iStatement() {}
func (*Select) iSelectStatement() {}
func (*Select) iTableSubquery() {}
func (*ValuesStatement) iSelectStatement() {}
func (*Union) iSelectStatement() {}
func (*Union) iTableSubquery() {}
func (*Load) iStatement() {}
func (*CreateDatabase) iStatement() {}
func (*AlterDatabase) iStatement() {}
Expand Down Expand Up @@ -2112,13 +2133,13 @@ type (

// Subquery represents a subquery used as an value expression.
Subquery struct {
Select SelectStatement
Select TableSubquery
}

// DerivedTable represents a subquery used as a table expression.
DerivedTable struct {
Lateral bool
Select SelectStatement
Select TableSubquery
}
)

Expand Down Expand Up @@ -3586,8 +3607,9 @@ type ValuesStatement struct {
Rows Values
ListArg ListArg

Order OrderBy
Limit *Limit
Comments *ParsedComments
Order OrderBy
Limit *Limit
}

// UpdateExprs represents a list of update expressions.
Expand Down
35 changes: 26 additions & 9 deletions go/vt/sqlparser/ast_clone.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 33 additions & 17 deletions go/vt/sqlparser/ast_copy_on_rewrite.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 148c41b

Please sign in to comment.