Skip to content

Commit

Permalink
Merge pull request #1108 from dolthub/fulghum/paren_wrapping
Browse files Browse the repository at this point in the history
Wrap function expressions for generated columns in parens
  • Loading branch information
fulghum authored Jan 9, 2025
2 parents 7f91aea + c8fb88a commit 59e3b9a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 6 additions & 0 deletions server/ast/column_table_def.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ func nodeColumnTableDef(ctx *Context, node *tree.ColumnTableDef) (*vitess.Column
if err != nil {
return nil, err
}

// GMS requires the AST to wrap function expressions in parens
if _, ok := generated.(*vitess.FuncExpr); ok {
generated = &vitess.ParenExpr{Expr: generated}
}

//TODO: need to add support for VIRTUAL in the parser
generatedStored = true
}
Expand Down
1 change: 0 additions & 1 deletion testing/go/create_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ func TestCreateTable(t *testing.T) {
},
{
Name: "create table with function in generated column",
Skip: true, // ERROR: column default function expressions must be enclosed in parentheses
SetUpScript: []string{
"create table t1 (a varchar(10) primary key, b varchar(10), c varchar(20) generated always as (concat(a,b)) stored);",
},
Expand Down

0 comments on commit 59e3b9a

Please sign in to comment.