Skip to content

Commit

Permalink
sql/parse: update sqlparser api. Fixes src-d#90. (src-d#92)
Browse files Browse the repository at this point in the history
* update to latest sqlparser api.
* use gitql/vitess fork instead of youtube/vitess.
  • Loading branch information
smola authored Jan 13, 2017
1 parent 1846ffc commit f470152
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions sql/parse/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/gitql/gitql/sql/expression"
"github.com/gitql/gitql/sql/plan"

"github.com/youtube/vitess/go/vt/sqlparser"
"github.com/gitql/vitess/go/vt/sqlparser"
)

const (
Expand Down Expand Up @@ -317,17 +317,23 @@ func valExprToExpression(ve sqlparser.ValExpr) (sql.Expression, error) {
switch v := ve.(type) {
default:
return nil, errUnsupported(v)
case sqlparser.StrVal:
return expression.NewLiteral(string(v), sql.String), nil
//TODO: case sqlparser.BoolVal:
// return expression.NewLiteral(bool(v), sql.Boolean), nil
case sqlparser.NumVal:
//TODO: Use smallest integer representation and widen later.
n, _ := strconv.ParseInt(string(v), 10, 64)
return expression.NewLiteral(n, sql.BigInteger), nil
case sqlparser.HexVal:
//TODO
return nil, errUnsupported(v)
case *sqlparser.SQLVal:
switch v.Type {
case sqlparser.StrVal:
return expression.NewLiteral(string(v.Val), sql.String), nil
case sqlparser.IntVal:
//TODO: Use smallest integer representation and widen later.
n, _ := strconv.ParseInt(string(v.Val), 10, 64)
return expression.NewLiteral(n, sql.BigInteger), nil
case sqlparser.HexVal:
//TODO
return nil, errUnsupported(v)
default:
//TODO
return nil, errUnsupported(v)
}
case sqlparser.BoolVal:
return expression.NewLiteral(bool(v), sql.Boolean), nil
case *sqlparser.NullVal:
//TODO
return expression.NewLiteral(nil, sql.Null), nil
Expand Down

0 comments on commit f470152

Please sign in to comment.