Skip to content

Commit

Permalink
feat: add comments to VALUES
Browse files Browse the repository at this point in the history
Signed-off-by: Andres Taylor <[email protected]>
  • Loading branch information
systay committed Jan 10, 2025
1 parent cc0851d commit 6e2c6bc
Show file tree
Hide file tree
Showing 12 changed files with 6,464 additions and 6,509 deletions.
5 changes: 3 additions & 2 deletions go/vt/sqlparser/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -3607,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
1 change: 1 addition & 0 deletions go/vt/sqlparser/ast_clone.go

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

4 changes: 3 additions & 1 deletion 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.

1 change: 1 addition & 0 deletions go/vt/sqlparser/ast_equals.go

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

2 changes: 1 addition & 1 deletion go/vt/sqlparser/ast_format.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (node *ValuesStatement) Format(buf *TrackedBuffer) {
if node.With != nil {
buf.astPrintf(node, "%v", node.With)
}
buf.WriteString("values ")
buf.astPrintf(node, "values %v", node.Comments)
if node.ListArg != "" {
buf.astPrintf(node, "%v", node.ListArg)
} else {
Expand Down
1 change: 1 addition & 0 deletions go/vt/sqlparser/ast_format_fast.go

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

11 changes: 7 additions & 4 deletions go/vt/sqlparser/ast_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3058,12 +3058,15 @@ func (node *ValuesStatement) GetColumnCount() int {
if len(node.Rows) > 0 {
return len(node.Rows[0])
}
return -1 // if what we have is a ListArg, we don't know the size of the output
panic("no columns available") // TODO: we need a better solution than a panic
}

func (node *ValuesStatement) GetColumns() SelectExprs {
//TODO implement me
panic("implement me")
func (node *ValuesStatement) GetColumns() (result SelectExprs) {
columnCount := node.GetColumnCount()
for i := range columnCount {
result = append(result, &AliasedExpr{Expr: NewColName(fmt.Sprintf("column_%d", i))})
}
panic("no columns available") // TODO: we need a better solution than a panic
}

func (node *ValuesStatement) SetComments(comments Comments) {}
Expand Down
5 changes: 5 additions & 0 deletions go/vt/sqlparser/ast_rewrite.go

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

3 changes: 3 additions & 0 deletions go/vt/sqlparser/ast_visit.go

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

2 changes: 2 additions & 0 deletions go/vt/sqlparser/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3875,6 +3875,8 @@ var (
input: "insert into t1(a1) values ('a'), ('b')",
}, {
input: "values row('a'), row('b')",
}, {
input: "values /*my comment*/ row('a'), row('b')",
}, {
input: `with x as (select * from t1 limit 1) values ROW('a1', (select x.a1 from x))`,
output: "with x as (select * from t1 limit 1) values row('a1', (select x.a1 from x))",
Expand Down
Loading

0 comments on commit 6e2c6bc

Please sign in to comment.