Skip to content
Permalink
Browse files
fix(spanner/spansql): fix SelectFromJoin behavior (#3571)
Fix #3570
  • Loading branch information
ww24 committed Jan 19, 2021
1 parent 56e18a6 commit e0887c762a4c58f29b3e5b49ee163a36a065463c
Showing with 24 additions and 1 deletion.
  1. +1 −1 spanner/spansql/sql.go
  2. +23 −0 spanner/spansql/sql_test.go
@@ -331,7 +331,7 @@ func (sfj SelectFromJoin) SQL() string {
// TODO: hints go here
str += sfj.RHS.SQL()
if sfj.On != nil {
str += " " + sfj.On.SQL()
str += " ON " + sfj.On.SQL()
} else if len(sfj.Using) > 0 {
str += " USING (" + idList(sfj.Using, ", ") + ")"
}
@@ -318,6 +318,29 @@ func TestSQL(t *testing.T) {
`TIMESTAMP '2014-09-27 12:34:56.123456 -07:00'`,
reparseExpr,
},
{
Query{
Select: Select{
List: []Expr{
ID("A"), ID("B"),
},
From: []SelectFrom{
SelectFromJoin{
Type: InnerJoin,
LHS: SelectFromTable{Table: "Table1"},
RHS: SelectFromTable{Table: "Table2"},
On: ComparisonOp{
LHS: PathExp{"Table1", "A"},
Op: Eq,
RHS: PathExp{"Table2", "A"},
},
},
},
},
},
"SELECT A, B FROM Table1 INNER JOIN Table2 ON Table1.A = Table2.A",
reparseQuery,
},
}
for _, test := range tests {
sql := test.data.SQL()

0 comments on commit e0887c7

Please sign in to comment.