Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion go/vt/sqlparser/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -1685,7 +1685,9 @@ func (node *CaseExpr) Format(buf *TrackedBuffer) {
func (node *Default) Format(buf *TrackedBuffer) {
buf.astPrintf(node, "default")
if node.ColName != "" {
buf.astPrintf(node, "(%s)", node.ColName)
buf.WriteString("(")
formatID(buf, node.ColName, strings.ToLower(node.ColName), NoAt)
buf.WriteString(")")
}
}

Expand Down
7 changes: 7 additions & 0 deletions go/vt/sqlparser/ast_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"testing"
"unsafe"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -784,3 +785,9 @@ func TestSplitStatementToPieces(t *testing.T) {
}
}
}

func TestDefaultStatus(t *testing.T) {
assert.Equal(t,
String(&Default{ColName: "status"}),
"default(`status`)")
}
2 changes: 2 additions & 0 deletions go/vt/sqlparser/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,8 @@ var (
input: "insert /* bool in on duplicate */ into a values (1, 2, 3) on duplicate key update b = values(a.b), c = d",
}, {
input: "insert /* bool expression on duplicate */ into a values (1, 2) on duplicate key update b = func(a), c = a > d",
}, {
input: "insert into user(username, `status`) values ('Chuck', default(`status`))",
}, {
input: "update /* simple */ a set b = 3",
}, {
Expand Down