Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added some unit test cases for CREATE TABLE parser #7279

Merged
merged 2 commits into from
Jan 11, 2021
Merged
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
21 changes: 21 additions & 0 deletions go/vt/sqlparser/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1078,13 +1078,31 @@ var (
output: "alter database d collate 'utf8_bin' character set geostd8 character set geostd8",
}, {
input: "create table a",
}, {
input: "CREATE TABLE a",
output: "create table a",
}, {
input: "create table `a`",
output: "create table a",
}, {
input: "create table a (\n\t`a` int\n)",
output: "create table a (\n\ta int\n)",
}, {
input: "create table `by` (\n\t`by` char\n)",
}, {
input: "create table test (\n\t__year year(4)\n)",
}, {
input: "create table a (\n\ta int not null\n)",
}, {
input: "create table a (\n\ta int not null default 0\n)",
}, {
input: "create table a (a int not null default 0, primary key(a))",
output: "create table a (\n\ta int not null default 0,\n\tprimary key (a)\n)",
}, {
input: "create table a (`a column` int)",
output: "create table a (\n\t`a column` int\n)",
}, {
input: "create table a (\n\ta varchar(32) not null default ''\n)",
}, {
input: "create table if not exists a (\n\t`a` int\n)",
output: "create table a (\n\ta int\n)",
Expand All @@ -1097,6 +1115,9 @@ var (
}, {
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: "create table a (b1 bool NOT NULL PRIMARY KEY, b2 boolean not null, KEY b2_idx(b))",
output: "create table a (\n\tb1 bool not null primary key,\n\tb2 boolean not null,\n\tKEY b2_idx (b)\n)",
}, {
input: "alter vschema create vindex hash_vdx using hash",
}, {
Expand Down