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

Add error for subqueries #552

Merged
merged 1 commit into from
Nov 20, 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
5 changes: 5 additions & 0 deletions sql/parse/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ var (
// ErrUnsupportedFeature is thrown when a feature is not already supported
ErrUnsupportedFeature = errors.NewKind("unsupported feature: %s")

// ErrUnsupportedSubqueryExpression is thrown because subqueries are not supported, yet.
ErrUnsupportedSubqueryExpression = errors.NewKind("unsupported subquery expression")

// ErrInvalidSQLValType is returned when a SQLVal type is not valid.
ErrInvalidSQLValType = errors.NewKind("invalid SQLVal of type: %d")

Expand Down Expand Up @@ -783,6 +786,8 @@ func exprToExpression(e sqlparser.Expr) (sql.Expression, error) {
return binaryExprToExpression(v)
case *sqlparser.UnaryExpr:
return unaryExprToExpression(v)
case *sqlparser.Subquery:
return nil, ErrUnsupportedSubqueryExpression.New()
}
}

Expand Down
7 changes: 4 additions & 3 deletions sql/parse/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -905,9 +905,10 @@ func TestParse(t *testing.T) {
}

var fixturesErrors = map[string]*errors.Kind{
`SHOW METHEMONEY`: ErrUnsupportedFeature,
`LOCK TABLES foo AS READ`: errUnexpectedSyntax,
`LOCK TABLES foo LOW_PRIORITY READ`: errUnexpectedSyntax,
`SHOW METHEMONEY`: ErrUnsupportedFeature,
`LOCK TABLES foo AS READ`: errUnexpectedSyntax,
`LOCK TABLES foo LOW_PRIORITY READ`: errUnexpectedSyntax,
`SELECT * FROM mytable WHERE i IN (SELECT i FROM foo)`: ErrUnsupportedSubqueryExpression,
}

func TestParseErrors(t *testing.T) {
Expand Down