Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions go/vt/sqlparser/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -1365,6 +1365,7 @@ type ColumnType struct {
// ColumnTypeOptions are generic field options for a column type
type ColumnTypeOptions struct {
NotNull bool
Null bool
Comment thread
GuptaManan100 marked this conversation as resolved.
Outdated
Autoincrement bool
Default Expr
OnUpdate Expr
Expand Down
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.

3 changes: 3 additions & 0 deletions go/vt/sqlparser/ast_format.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,9 @@ func (ct *ColumnType) Format(buf *TrackedBuffer) {
if ct.Collate != "" {
buf.astPrintf(ct, " %s %s", keywordStrings[COLLATE], ct.Collate)
}
if ct.Options.Null {
buf.astPrintf(ct, " %s", keywordStrings[NULL])
}
if ct.Options.NotNull {
buf.astPrintf(ct, " %s %s", keywordStrings[NOT], keywordStrings[NULL])
}
Expand Down
4 changes: 4 additions & 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: 11 additions & 0 deletions go/vt/sqlparser/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1146,6 +1146,9 @@ var (
}, {
input: "CREATE TABLE aipk (id INT AUTO_INCREMENT PRIMARY KEY)",
output: "create table aipk (\n\tid INT auto_increment primary key\n)",
}, {
input: "create table foo (f timestamp null not null , g timestamp not null null)",
Comment thread
GuptaManan100 marked this conversation as resolved.
output: "create table foo (\n\tf timestamp not null,\n\tg timestamp null\n)",
}, {
input: "alter vschema create vindex hash_vdx using hash",
}, {
Expand Down Expand Up @@ -2556,6 +2559,14 @@ func TestCreateTable(t *testing.T) {
" col_multipolygon2 multipolygon not null\n" +
")",

// test null columns
"create table foo (\n" +
" id int primary key,\n" +
" a varchar(255) null,\n" +
" b varchar(255) null default 'foo',\n" +
" c timestamp null default current_timestamp()\n" +
")",

// test defining indexes separately
"create table t (\n" +
" id int auto_increment,\n" +
Expand Down
Loading