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

Commit 2ee52e3

Browse files
authored
Merge pull request #552 from kuba--/fix-622/subquery
Add error for subqueries
2 parents 5e22935 + 3b2d213 commit 2ee52e3

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

sql/parse/parse.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ var (
2525
// ErrUnsupportedFeature is thrown when a feature is not already supported
2626
ErrUnsupportedFeature = errors.NewKind("unsupported feature: %s")
2727

28+
// ErrUnsupportedSubqueryExpression is thrown because subqueries are not supported, yet.
29+
ErrUnsupportedSubqueryExpression = errors.NewKind("unsupported subquery expression")
30+
2831
// ErrInvalidSQLValType is returned when a SQLVal type is not valid.
2932
ErrInvalidSQLValType = errors.NewKind("invalid SQLVal of type: %d")
3033

@@ -783,6 +786,8 @@ func exprToExpression(e sqlparser.Expr) (sql.Expression, error) {
783786
return binaryExprToExpression(v)
784787
case *sqlparser.UnaryExpr:
785788
return unaryExprToExpression(v)
789+
case *sqlparser.Subquery:
790+
return nil, ErrUnsupportedSubqueryExpression.New()
786791
}
787792
}
788793

sql/parse/parse_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -905,9 +905,10 @@ func TestParse(t *testing.T) {
905905
}
906906

907907
var fixturesErrors = map[string]*errors.Kind{
908-
`SHOW METHEMONEY`: ErrUnsupportedFeature,
909-
`LOCK TABLES foo AS READ`: errUnexpectedSyntax,
910-
`LOCK TABLES foo LOW_PRIORITY READ`: errUnexpectedSyntax,
908+
`SHOW METHEMONEY`: ErrUnsupportedFeature,
909+
`LOCK TABLES foo AS READ`: errUnexpectedSyntax,
910+
`LOCK TABLES foo LOW_PRIORITY READ`: errUnexpectedSyntax,
911+
`SELECT * FROM mytable WHERE i IN (SELECT i FROM foo)`: ErrUnsupportedSubqueryExpression,
911912
}
912913

913914
func TestParseErrors(t *testing.T) {

0 commit comments

Comments
 (0)