Skip to content

Various small parser improvements #249

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

Merged
merged 5 commits into from
Jun 21, 2023
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
22 changes: 22 additions & 0 deletions go/vt/sqlparser/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ type parseTest struct {

var (
validSQL = []parseTest{
{
// INVISIBLE should parse, but be a no-op (for now)
input: "create table t (pk int primary key, c1 int INVISIBLE)",
output: "create table t (\n\tpk int primary key,\n\tc1 int\n)",
},
{
// INVISIBLE should parse, but be a no-op (for now)
input: "alter table t add column c1 int INVISIBLE",
output: "alter table t add column (\n\tc1 int\n)",
},
{
input: "ALTER TABLE webhook_events ADD COLUMN event varchar(255) DEFAULT NULL;",
output: "alter table webhook_events add column (\n\t`event` varchar(255) default null\n)",
Expand Down Expand Up @@ -1489,6 +1499,8 @@ var (
output: "create or replace view a as select current_timestamp()",
}, {
input: "create trigger t1 before update on foo for each row precedes bar update xxy set baz = 1 where a = b",
}, {
input: "create trigger t2 before update on foo for each row precedes bar call myStoredProc(foo)",
}, {
input: "create trigger dbName.trigger1 before update on foo for each row precedes bar update xxy set baz = 1 where a = b",
}, {
Expand Down Expand Up @@ -4417,6 +4429,8 @@ func TestFunctionCalls(t *testing.T) {
"select CONNECTION_ID() from dual",
"select CONV() from dual",
"select CONVERT('abc', binary) from dual",
"select CONVERT(foo, DOUBLE)",
"select CONVERT(foo, FLOAT)",
"select CONVERT_TZ() from dual",
"select COS() from dual",
"select COT() from dual",
Expand Down Expand Up @@ -4796,6 +4810,14 @@ func TestFunctionCalls(t *testing.T) {
input: "select LOCALTIMESTAMP from dual",
output: "select LOCALTIMESTAMP()",
},
{
input: "SELECT CAST(foo AS DOUBLE)",
output: "select CAST(foo, DOUBLE)",
},
{
input: "SELECT CAST(foo AS FLOAT)",
output: "select CAST(foo, FLOAT)",
},
}

// Unimplemented or broken functionality
Expand Down
Loading