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
41 changes: 41 additions & 0 deletions go/vt/sqlparser/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,35 @@ var (
}, {
input: "select a from (select 1 as a from tbl1 union select 2 from tbl2) as t (a, b)",
},
// https://github.com/dolthub/dolt/issues/8058
{
input: "SELECT SUM(found) FROM ((SELECT 2 as found FROM dual)) as all_found",
output: "select SUM(`found`) from (select 2 as `found`) as all_found",
},
{
input: "SELECT SUM(found) FROM (((SELECT 2 as found FROM dual))) as all_found",
output: "select SUM(`found`) from (select 2 as `found`) as all_found",
},
{
input: "SELECT EXISTS ((SELECT 1))",
output: "select exists (select 1)",
},
{
input: "SELECT EXISTS (((SELECT 1)))",
output: "select exists (select 1)",
},
{
input: "WITH t AS ((SELECT 1)) SELECT * FROM t",
output: "with t as (select 1) select * from t",
},
{
input: "WITH t AS (((SELECT 1))) SELECT * FROM t",
output: "with t as (select 1) select * from t",
},
{
input: "select a from ((values (1, 2), ('a', 'b'))) as t (a, b)",
output: "select a from (values row(1, 2), row('a', 'b')) as t (a, b)",
},
{
input: "select a from (values (1, 2), ('a', 'b')) as t (a, b)",
output: "select a from (values row(1, 2), row('a', 'b')) as t (a, b)",
Expand Down Expand Up @@ -6148,6 +6177,18 @@ func TestInvalid(t *testing.T) {
input: "select a from (select * from tbl)",
err: "Every derived table must have its own alias",
},
{
input: "select a from ((select * from tbl))",
err: "Every derived table must have its own alias",
},
{
input: "select a from (((select * from tbl)))",
err: "Every derived table must have its own alias",
},
{
input: "select * from ((values (1, 2)))",
err: "Every derived table must have its own alias",
},
{
input: "select a, b from (select * from tbl) sort by a",
err: "syntax error",
Expand Down
Loading
Loading