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
9 changes: 6 additions & 3 deletions server/ast/select.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ func nodeSelectExpr(ctx *Context, node tree.SelectExpr) (vitess.SelectExpr, erro
case tree.UnqualifiedStar:
return &vitess.StarExpr{}, nil
case *tree.UnresolvedName:
if expr.NumParts > 2 {
return nil, errors.Errorf("referencing items outside the schema or database is not yet supported")
}
if expr.Star {
var tableName vitess.TableName
if expr.NumParts > 2 {
tableName.SchemaQualifier = vitess.NewTableIdent(expr.Parts[2])
}
if expr.NumParts == 2 {
tableName.Name = vitess.NewTableIdent(expr.Parts[1])
}
Expand All @@ -123,6 +123,9 @@ func nodeSelectExpr(ctx *Context, node tree.SelectExpr) (vitess.SelectExpr, erro
}, nil
} else {
var tableName vitess.TableName
if expr.NumParts > 2 {
tableName.SchemaQualifier = vitess.NewTableIdent(expr.Parts[2])
}
if expr.NumParts == 2 {
tableName.Name = vitess.NewTableIdent(expr.Parts[1])
}
Expand Down
18 changes: 2 additions & 16 deletions testing/go/dolt_tables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ func TestUserSpaceDoltTables(t *testing.T) {
Expected: []sql.Row{{"main"}},
},
{
Skip: true, // TODO: referencing items outside the schema or database is not yet supported
Query: `SELECT dolt.branches.name FROM dolt.branches`,
Expected: []sql.Row{{"main"}},
},
Expand Down Expand Up @@ -213,9 +212,8 @@ func TestUserSpaceDoltTables(t *testing.T) {
Expected: []sql.Row{{"public.test", "id"}},
},
{
Skip: true, // TODO: referencing items outside the schema or database is not yet supported
Query: `SELECT dolt.column_diff.commit_hash FROM dolt.column_diff`,
Expected: []sql.Row{},
Query: `SELECT dolt.column_diff.table_name FROM dolt.column_diff`,
Expected: []sql.Row{{"public.test"}},
},
{
Query: `SELECT dolt_column_diff.table_name, dolt_column_diff.column_name FROM dolt_column_diff`,
Expand Down Expand Up @@ -291,7 +289,6 @@ func TestUserSpaceDoltTables(t *testing.T) {
Expected: []sql.Row{{2}},
},
{
Skip: true, // TODO: referencing items outside the schema or database is not yet supported
Query: `SELECT dolt.commit_ancestors.parent_index FROM dolt.commit_ancestors`,
Expected: []sql.Row{{0}, {0}},
},
Expand Down Expand Up @@ -469,7 +466,6 @@ func TestUserSpaceDoltTables(t *testing.T) {
Expected: []sql.Row{{2}},
},
{
Skip: true, // TODO: referencing items outside the schema or database is not yet supported
Query: `SELECT dolt.commits.message FROM dolt.commits`,
Expected: []sql.Row{{"CREATE DATABASE"}, {"Initialize data repository"}},
},
Expand Down Expand Up @@ -562,7 +558,6 @@ func TestUserSpaceDoltTables(t *testing.T) {
Expected: []sql.Row{{"test", Numeric("1")}},
},
{
Skip: true, // TODO: referencing items outside the schema or database is not yet supported
Query: `SELECT dolt.conflicts.table FROM dolt.conflicts`,
Expected: []sql.Row{{"test"}},
},
Expand Down Expand Up @@ -771,7 +766,6 @@ func TestUserSpaceDoltTables(t *testing.T) {
Expected: []sql.Row{{"test", Numeric("2")}},
},
{
Skip: true, // TODO: referencing items outside the schema or database is not yet supported
Query: `SELECT dolt.constraint_violations.table FROM dolt.constraint_violations`,
Expected: []sql.Row{{"test"}},
},
Expand Down Expand Up @@ -982,7 +976,6 @@ func TestUserSpaceDoltTables(t *testing.T) {
},
},
{
Skip: true, // TODO: referencing items outside the schema or database is not yet supported
Query: `SELECT dolt.docs.doc_name FROM dolt.docs`,
Expected: []sql.Row{{"README.md"}},
},
Expand Down Expand Up @@ -1137,7 +1130,6 @@ func TestUserSpaceDoltTables(t *testing.T) {
Expected: []sql.Row{{"public.test"}},
},
{
Skip: true, // TODO: referencing items outside the schema or database is not yet supported
Query: `SELECT dolt.diff.table_name FROM dolt.diff`,
Expected: []sql.Row{{"public.test"}},
},
Expand Down Expand Up @@ -1687,7 +1679,6 @@ func TestUserSpaceDoltTables(t *testing.T) {
Expected: []sql.Row{{"f"}},
},
{
Skip: true, // TODO: referencing items outside the schema or database is not yet supported
Query: `SELECT dolt.merge_status.is_merging FROM dolt.merge_status`,
Expected: []sql.Row{{"f"}},
},
Expand Down Expand Up @@ -1924,7 +1915,6 @@ func TestUserSpaceDoltTables(t *testing.T) {
Expected: []sql.Row{},
},
{
Skip: true, // TODO: referencing items outside the schema or database is not yet supported
Query: `SELECT dolt.status.table_name FROM dolt.status`,
Expected: []sql.Row{{"public.t"}},
},
Expand Down Expand Up @@ -2005,7 +1995,6 @@ func TestUserSpaceDoltTables(t *testing.T) {
Expected: []sql.Row{{"v1"}},
},
{
Skip: true, // TODO: referencing items outside the schema or database is not yet supported
Query: `SELECT dolt.tags.tag_name FROM dolt.tags`,
Expected: []sql.Row{{"v1"}},
},
Expand Down Expand Up @@ -2336,7 +2325,6 @@ func TestUserSpaceDoltTables(t *testing.T) {
Expected: []sql.Row{},
},
{
Skip: true, // TODO: referencing items outside the schema or database is not yet supported
Query: `SELECT dolt.remote_branches.name FROM dolt.remote_branches`,
Expected: []sql.Row{},
},
Expand Down Expand Up @@ -2417,7 +2405,6 @@ func TestUserSpaceDoltTables(t *testing.T) {
Expected: []sql.Row{{"origin"}},
},
{
Skip: true, // TODO: referencing items outside the schema or database is not yet supported
Query: `SELECT dolt.remotes.name FROM dolt.remotes`,
Expected: []sql.Row{{"origin"}},
},
Expand Down Expand Up @@ -2507,7 +2494,6 @@ func TestUserSpaceDoltTables(t *testing.T) {
Expected: []sql.Row{{"test"}},
},
{
Skip: true, // TODO: referencing items outside the schema or database is not yet supported
Query: `SELECT dolt.schema_conflicts.table_name FROM dolt.schema_conflicts`,
Expected: []sql.Row{{"test"}},
},
Expand Down
32 changes: 32 additions & 0 deletions testing/go/insert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ func TestInsert(t *testing.T) {
"CREATE TABLE t (i serial, j INT)",
"CREATE TABLE u (u uuid DEFAULT 'ac1f3e2d-1e4b-4d3e-8b1f-2b7f1e7f0e3d', j INT)",
"CREATE TABLE s (v1 varchar DEFAULT 'hello', v2 varchar DEFAULT 'world')",
"CREATE SCHEMA ts",
"CREATE TABLE ts.t (i serial, j INT)",
},
Assertions: []ScriptTestAssertion{
{
Expand Down Expand Up @@ -244,6 +246,36 @@ func TestInsert(t *testing.T) {
Query: "INSERT INTO t (j) VALUES (5), (6), (7) RETURNING i, doesnotexist(j)",
ExpectedErr: "function: 'doesnotexist' not found",
},
{
Query: "INSERT INTO public.t (j) VALUES (8) RETURNING t.j",
Expected: []sql.Row{{8}},
},
{
Query: "INSERT INTO public.t (j) VALUES (9) RETURNING public.t.j",
Expected: []sql.Row{{9}},
},
{
Query: "INSERT INTO ts.t (j) VALUES (10) RETURNING ts.t.j",
Expected: []sql.Row{{10}},
},
{
Skip: true, // TODO: unable to find field with index 2 in row of 2 columns
Query: "INSERT INTO public.t (j) VALUES ($1) RETURNING j;",
BindVars: []any{11},
Expected: []sql.Row{{11}},
},
{
Skip: true, // TODO: unable to find field with index 2 in row of 2 columns
Query: "INSERT INTO public.t (j) VALUES ($1) RETURNING t.j;",
BindVars: []any{12},
Expected: []sql.Row{{12}},
},
{
Skip: true, // TODO: unable to find field with index 2 in row of 2 columns
Query: "INSERT INTO public.t (j) VALUES ($1) RETURNING public.t.j;",
BindVars: []any{13},
Expected: []sql.Row{{13}},
},
},
},
{
Expand Down