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

Commit 5a108b2

Browse files
authored
Merge pull request #554 from kuba--/fix-553/join
Add explicit error when ON clause is missed for JOIN statement
2 parents 2ee52e3 + a561a62 commit 5a108b2

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

sql/parse/parse.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,11 +493,14 @@ func tableExprToTable(
493493
return plan.NewNaturalJoin(left, right), nil
494494
}
495495

496+
if t.Condition.On == nil {
497+
return nil, ErrUnsupportedSyntax.New("missed ON clause for JOIN statement")
498+
}
499+
496500
cond, err := exprToExpression(t.Condition.On)
497501
if err != nil {
498502
return nil, err
499503
}
500-
501504
return plan.NewInnerJoin(left, right, cond), nil
502505
}
503506
}

sql/parse/parse_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,10 @@ var fixturesErrors = map[string]*errors.Kind{
909909
`LOCK TABLES foo AS READ`: errUnexpectedSyntax,
910910
`LOCK TABLES foo LOW_PRIORITY READ`: errUnexpectedSyntax,
911911
`SELECT * FROM mytable WHERE i IN (SELECT i FROM foo)`: ErrUnsupportedSubqueryExpression,
912+
`SELECT * FROM files
913+
JOIN commit_files
914+
JOIN refs
915+
`: ErrUnsupportedSyntax,
912916
}
913917

914918
func TestParseErrors(t *testing.T) {

0 commit comments

Comments
 (0)