From 9461a11c971720d5b351b481f0ca0e78872966a2 Mon Sep 17 00:00:00 2001 From: Jake Wheat Date: Tue, 17 Dec 2013 12:24:37 +0200 Subject: [PATCH] get star parsing working everywhere --- Language/SQL/SimpleSQL/Parser.lhs | 11 +++++------ tools/Language/SQL/SimpleSQL/Postgres.lhs | 2 +- tools/Language/SQL/SimpleSQL/ScalarExprs.lhs | 1 + 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Language/SQL/SimpleSQL/Parser.lhs b/Language/SQL/SimpleSQL/Parser.lhs index 3f98710..2a1d7ec 100644 --- a/Language/SQL/SimpleSQL/Parser.lhs +++ b/Language/SQL/SimpleSQL/Parser.lhs @@ -126,7 +126,8 @@ of dots. == star -used in select *, select x.*, and agg(*) variations. +used in select *, select x.*, and agg(*) variations, and some other +places as well. > star :: P ScalarExpr > star = choice [Star <$ symbol "*" @@ -147,8 +148,7 @@ aggregate([all|distinct] args [order by orderitems]) > makeApp > <$> identifierString > <*> parens ((,,) <$> try duplicates -> <*> choice [(:[]) <$> try star -> ,commaSep scalarExpr'] +> <*> choice [commaSep scalarExpr'] > <*> try (optionMaybe orderBy)) > where > makeApp i (Nothing,es,Nothing) = App i es @@ -445,6 +445,7 @@ could at least do with some heavy explanation. > ,prefixUnaryOp > ,try app > ,try dottedIden +> ,try star > ,identifier > ,sparens] @@ -474,9 +475,7 @@ easy to ensure that this fix is only applied once to each scalar expression tree (for efficiency and code clarity). > scalarExpr :: P ScalarExpr -> scalarExpr = -> choice [try star -> ,fixFixities sqlFixities <$> scalarExpr'] +> scalarExpr = fixFixities sqlFixities <$> scalarExpr' ------------------------------------------------- diff --git a/tools/Language/SQL/SimpleSQL/Postgres.lhs b/tools/Language/SQL/SimpleSQL/Postgres.lhs index 2baa09e..d380dc2 100644 --- a/tools/Language/SQL/SimpleSQL/Postgres.lhs +++ b/tools/Language/SQL/SimpleSQL/Postgres.lhs @@ -22,7 +22,7 @@ TODO: get all the commented out tests working > \ FROM states;" > ,"SELECT ROW(1,2.5,'this is a test');" -> --,"SELECT ROW(t.*, 42) FROM t;" -- needs the .* parsing to be enabled in more contexts +> ,"SELECT ROW(t.*, 42) FROM t;" > ,"SELECT ROW(t.f1, t.f2, 42) FROM t;" > ,"SELECT getf1(CAST(ROW(11,'this is a test',2.5) AS myrowtype));" diff --git a/tools/Language/SQL/SimpleSQL/ScalarExprs.lhs b/tools/Language/SQL/SimpleSQL/ScalarExprs.lhs index 91fefcc..6a78167 100644 --- a/tools/Language/SQL/SimpleSQL/ScalarExprs.lhs +++ b/tools/Language/SQL/SimpleSQL/ScalarExprs.lhs @@ -48,6 +48,7 @@ Tests for parsing scalar expressions > star = Group "star" $ map (uncurry TestScalarExpr) > [("*", Star) > ,("t.*", Star2 "t") +> ,("ROW(t.*,42)", App "ROW" [Star2 "t", NumLit "42"]) > ] > app :: TestItem