mirror of
https://github.com/pikami/cosmium.git
synced 2025-12-19 08:50:46 +00:00
Added support for table alias; Make AS keyword optional #9
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/pikami/cosmium/parsers"
|
||||
testutils "github.com/pikami/cosmium/test_utils"
|
||||
)
|
||||
|
||||
func Test_Parse_SubQuery(t *testing.T) {
|
||||
@@ -22,7 +23,7 @@ func Test_Parse_SubQuery(t *testing.T) {
|
||||
Alias: "c",
|
||||
Type: parsers.SelectItemTypeSubQuery,
|
||||
Value: parsers.SelectStmt{
|
||||
Table: parsers.Table{Value: "cc"},
|
||||
Table: parsers.Table{SelectItem: testutils.SelectItem_Path("cc")},
|
||||
SelectItems: []parsers.SelectItem{
|
||||
{Path: []string{"cc", "info"}, IsTopLevel: true},
|
||||
},
|
||||
@@ -42,9 +43,7 @@ func Test_Parse_SubQuery(t *testing.T) {
|
||||
{Path: []string{"c", "id"}},
|
||||
{Path: []string{"cc", "name"}},
|
||||
},
|
||||
Table: parsers.Table{
|
||||
Value: "c",
|
||||
},
|
||||
Table: parsers.Table{SelectItem: testutils.SelectItem_Path("c")},
|
||||
JoinItems: []parsers.JoinItem{
|
||||
{
|
||||
Table: parsers.Table{
|
||||
@@ -55,13 +54,12 @@ func Test_Parse_SubQuery(t *testing.T) {
|
||||
Type: parsers.SelectItemTypeSubQuery,
|
||||
Value: parsers.SelectStmt{
|
||||
SelectItems: []parsers.SelectItem{
|
||||
{Path: []string{"tag", "name"}},
|
||||
testutils.SelectItem_Path("tag", "name"),
|
||||
},
|
||||
Table: parsers.Table{
|
||||
Value: "tag",
|
||||
SelectItem: parsers.SelectItem{
|
||||
Path: []string{"c", "tags"},
|
||||
},
|
||||
Value: "tag",
|
||||
SelectItem: testutils.SelectItem_Path("c", "tags"),
|
||||
IsInSelect: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -82,10 +80,10 @@ func Test_Parse_SubQuery(t *testing.T) {
|
||||
WHERE hasTags`,
|
||||
parsers.SelectStmt{
|
||||
SelectItems: []parsers.SelectItem{
|
||||
{Path: []string{"c", "id"}},
|
||||
testutils.SelectItem_Path("c", "id"),
|
||||
},
|
||||
Table: parsers.Table{
|
||||
Value: "c",
|
||||
SelectItem: testutils.SelectItem_Path("c"),
|
||||
},
|
||||
JoinItems: []parsers.JoinItem{
|
||||
{
|
||||
@@ -100,13 +98,12 @@ func Test_Parse_SubQuery(t *testing.T) {
|
||||
Type: parsers.SelectItemTypeSubQuery,
|
||||
Value: parsers.SelectStmt{
|
||||
SelectItems: []parsers.SelectItem{
|
||||
{Path: []string{"tag", "name"}},
|
||||
testutils.SelectItem_Path("tag", "name"),
|
||||
},
|
||||
Table: parsers.Table{
|
||||
Value: "tag",
|
||||
SelectItem: parsers.SelectItem{
|
||||
Path: []string{"c", "tags"},
|
||||
},
|
||||
Value: "tag",
|
||||
SelectItem: testutils.SelectItem_Path("c", "tags"),
|
||||
IsInSelect: true,
|
||||
},
|
||||
Exists: true,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user