Skip to content

Commit

Permalink
Merge pull request #4609 from kuba--/bool-type
Browse files Browse the repository at this point in the history
Support bool as column type
  • Loading branch information
sougou authored Feb 12, 2019
2 parents b37202e + 3d8b489 commit 613bb78
Show file tree
Hide file tree
Showing 4 changed files with 2,834 additions and 2,814 deletions.
2 changes: 2 additions & 0 deletions go/vt/sqlparser/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -1170,6 +1170,8 @@ func (ct *ColumnType) SQLType() querypb.Type {
return sqltypes.Uint64
}
return sqltypes.Int64
case keywordStrings[BOOL], keywordStrings[BOOLEAN]:
return sqltypes.Uint8
case keywordStrings[TEXT]:
return sqltypes.Text
case keywordStrings[TINYTEXT]:
Expand Down
10 changes: 10 additions & 0 deletions go/vt/sqlparser/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,9 @@ var (
}, {
input: "create table a (a int, b char, c garbage)",
output: "create table a",
}, {
input: "create table a (b1 bool not null primary key, b2 boolean not null)",
output: "create table a (\n\tb1 bool not null primary key,\n\tb2 boolean not null\n)",
}, {
input: "alter vschema create vindex hash_vdx using hash",
}, {
Expand Down Expand Up @@ -2040,6 +2043,13 @@ func TestCreateTable(t *testing.T) {
" stats_sample_pages 1,\n" +
" tablespace tablespace_name storage disk,\n" +
" tablespace tablespace_name\n",

// boolean columns
"create table t (\n" +
" bi bigint not null primary key,\n" +
" b1 bool not null,\n" +
" b2 boolean\n" +
")",
}
for _, sql := range validSQL {
sql = strings.TrimSpace(sql)
Expand Down
Loading

0 comments on commit 613bb78

Please sign in to comment.