Skip to content
This repository has been archived by the owner on Jan 28, 2021. It is now read-only.

upgrade vitess to v1.4.0 #545

Merged
merged 1 commit into from
Nov 13, 2018
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
17 changes: 16 additions & 1 deletion engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ var queries = []struct {
"SELECT substring(s, 2, 3) FROM mytable",
[]sql.Row{{"irs"}, {"eco"}, {"hir"}},
},
{
`SELECT substring("foo", 2, 2)`,
[]sql.Row{{"oo"}},
},
{
"SELECT YEAR('2007-12-11') FROM mytable",
[]sql.Row{{int32(2007)}, {int32(2007)}, {int32(2007)}},
Expand Down Expand Up @@ -137,6 +141,12 @@ var queries = []struct {
{"first", "irst", "rst"},
},
},
{
`SELECT substring("first", 1), substring("second", 2), substring("third", 3)`,
[]sql.Row{
{"first", "econd", "ird"},
},
},
{
"SELECT substring(s2, -1), substring(s2, -2), substring(s2, -3) FROM othertable ORDER BY i2",
[]sql.Row{
Expand All @@ -145,7 +155,12 @@ var queries = []struct {
{"t", "st", "rst"},
},
},

{
`SELECT substring("first", -1), substring("second", -2), substring("third", -3)`,
[]sql.Row{
{"t", "nd", "ird"},
},
},
{
"SELECT s FROM mytable INNER JOIN othertable " +
"ON substring(s2, 1, 2) != '' AND i = i2",
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ require (
golang.org/x/net v0.0.0-20181029044818-c44066c5c816 // indirect
google.golang.org/grpc v1.16.0 // indirect
gopkg.in/src-d/go-errors.v1 v1.0.0
gopkg.in/src-d/go-vitess.v1 v1.3.0
gopkg.in/src-d/go-vitess.v1 v1.4.0
)
15 changes: 10 additions & 5 deletions sql/parse/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,7 @@ func convertCreateTable(c *sqlparser.DDL) (sql.Node, error) {
}

return plan.NewCreateTable(
sql.UnresolvedDatabase(""),
c.NewName.Name.String(),
schema,
), nil
sql.UnresolvedDatabase(""), c.Table.Name.String(), schema), nil
}

func convertInsert(ctx *sql.Context, i *sqlparser.Insert) (sql.Node, error) {
Expand Down Expand Up @@ -656,7 +653,15 @@ func exprToExpression(e sqlparser.Expr) (sql.Expression, error) {
case *sqlparser.Default:
return expression.NewDefaultColumn(v.ColName), nil
case *sqlparser.SubstrExpr:
name, err := exprToExpression(v.Name)
var (
name sql.Expression
err error
)
if v.Name != nil {
name, err = exprToExpression(v.Name)
} else {
name, err = exprToExpression(v.StrVal)
}
if err != nil {
return nil, err
}
Expand Down