Skip to content

Commit a178ba7

Browse files
committed
Require "ON" constraint for all joins other than comma-joins.
1 parent a3be5f1 commit a178ba7

File tree

1 file changed

+23
-28
lines changed

1 file changed

+23
-28
lines changed

src/Rezoom.SQL.Compiler/CoreParser.fs

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -636,39 +636,34 @@ let private joinType =
636636
%% ws -|> Inner
637637
]
638638

639-
let private joinConstraint =
640-
%[
641-
%% kw "ON" -- +.expr -- ws -|> JoinOn
642-
preturn JoinUnconstrained
643-
]
639+
let private joinConstraint = %% kw "ON" -- +.expr -- ws -|> JoinOn
644640

645641
let private tableExpr = // parses table expr (with left-associative joins)
646642
let term = tableOrSubquery |> withSource
647643
let natural = %% kw "NATURAL" -|> ()
648644
let join =
649-
%% +.(
650-
%[
651-
%% ','
652-
-|> fun left right constr ->
653-
{ JoinType = Inner
654-
LeftTable = left
655-
RightTable = right
656-
Constraint = constr
657-
} |> Join
658-
%% +.(natural * zeroOrOne) -- +.joinType -- kw "JOIN"
659-
-|> fun natural join left right constr ->
660-
let joinType = if Option.isSome natural then Natural join else join
661-
{ JoinType = joinType
662-
LeftTable = left
663-
RightTable = right
664-
Constraint = constr
665-
} |> Join
666-
] |> withSource)
667-
-- ws
668-
-- +.term
669-
-- ws
670-
-- +.joinConstraint
671-
-|> fun f joinTo joinOn left -> { TableExpr.Source = f.Source; Value = f.Value left joinTo joinOn }
645+
%[ %% ',' -- ws -- +.withSource term
646+
-|> fun right left ->
647+
{ TableExpr.Source = right.Source
648+
Value =
649+
{ JoinType = Inner
650+
LeftTable = left
651+
RightTable = right.Value
652+
Constraint = JoinUnconstrained
653+
} |> Join
654+
}
655+
%% +.(natural * zeroOrOne) -- +.withSource joinType -- kw "JOIN" -- +.term -- ws -- +.joinConstraint
656+
-|> fun natural join right constr left ->
657+
let joinType = if Option.isSome natural then Natural join.Value else join.Value
658+
{ TableExpr.Source = join.Source
659+
Value =
660+
{ JoinType = joinType
661+
LeftTable = left
662+
RightTable = right
663+
Constraint = constr
664+
} |> Join
665+
}
666+
]
672667
%% +.term
673668
-- ws
674669
-- +.(join * qty.[0..])

0 commit comments

Comments
 (0)