From bfe07dce53fd20b489359994ce26eb9fd3e84689 Mon Sep 17 00:00:00 2001 From: Jake Wheat Date: Tue, 17 Dec 2013 16:33:56 +0200 Subject: [PATCH] fix the lateral parsing issue and broken test --- Language/SQL/SimpleSQL/Parser.lhs | 3 ++- tools/Language/SQL/SimpleSQL/TableRefs.lhs | 13 ++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Language/SQL/SimpleSQL/Parser.lhs b/Language/SQL/SimpleSQL/Parser.lhs index f88c3e2..f75efaf 100644 --- a/Language/SQL/SimpleSQL/Parser.lhs +++ b/Language/SQL/SimpleSQL/Parser.lhs @@ -514,7 +514,8 @@ tref > tref = nonJoinTref >>= optionSuffix joinTrefSuffix > nonJoinTref = choice [try (TRQueryExpr <$> parens queryExpr) > ,TRParens <$> parens tref -> ,TRLateral <$> (try (keyword_ "lateral") *> tref) +> ,TRLateral <$> (try (keyword_ "lateral") +> *> nonJoinTref) > ,try (TRFunction <$> name > <*> parens (commaSep scalarExpr)) > ,TRSimple <$> name] diff --git a/tools/Language/SQL/SimpleSQL/TableRefs.lhs b/tools/Language/SQL/SimpleSQL/TableRefs.lhs index 466d3d6..00c86ef 100644 --- a/tools/Language/SQL/SimpleSQL/TableRefs.lhs +++ b/tools/Language/SQL/SimpleSQL/TableRefs.lhs @@ -28,9 +28,8 @@ these lateral queries make no sense but the syntax is valid > ,("select a from lateral a,b" > ,ms [TRLateral $ TRSimple "a", TRSimple "b"]) -> -- not sure what the problem is -> --,("select from a, lateral b" -> -- ,ms [TRSimple "a", TRLateral $ TRSimple "b"]) +> ,("select a from a, lateral b" +> ,ms [TRSimple "a", TRLateral $ TRSimple "b"]) > ,("select a from a natural join lateral b" > ,ms [TRJoin (TRSimple "a") JInner @@ -38,10 +37,10 @@ these lateral queries make no sense but the syntax is valid > (Just JoinNatural)]) > -- the lateral binds on the outside of the join which is incorrect -> --,("select a from lateral a natural join lateral b" -> -- ,ms [TRJoin (TRLateral $ TRSimple "a") JInner -> -- (TRLateral $ TRSimple "b") -> -- (Just JoinNatural)]) +> ,("select a from lateral a natural join lateral b" +> ,ms [TRJoin (TRLateral $ TRSimple "a") JInner +> (TRLateral $ TRSimple "b") +> (Just JoinNatural)]) > ,("select a from t inner join u on expr"