From 1be27eca58921d51e6b311687e86b39cf6ee1659 Mon Sep 17 00:00:00 2001 From: Jake Wheat Date: Thu, 19 Dec 2013 10:34:32 +0200 Subject: [PATCH] rename Duplicates -> SetQuantifier + qeDuplicates -> qeSetQuantifier --- Language/SQL/SimpleSQL/Parser.lhs | 2 +- Language/SQL/SimpleSQL/Pretty.lhs | 4 ++-- Language/SQL/SimpleSQL/Syntax.lhs | 19 +++++++++++++------ .../SQL/SimpleSQL/QueryExprComponents.lhs | 8 +++++++- 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/Language/SQL/SimpleSQL/Parser.lhs b/Language/SQL/SimpleSQL/Parser.lhs index c8b9088..d18752b 100644 --- a/Language/SQL/SimpleSQL/Parser.lhs +++ b/Language/SQL/SimpleSQL/Parser.lhs @@ -158,7 +158,7 @@ aggregate([all|distinct] args [order by orderitems]) > makeApp i (Nothing,es,Nothing) = App i es > makeApp i (d,es,od) = AggregateApp i d es (fromMaybe [] od) -> duplicates :: P (Maybe Duplicates) +> duplicates :: P (Maybe SetQuantifier) > duplicates = optionMaybe $ try $ > choice [All <$ keyword_ "all" > ,Distinct <$ keyword "distinct"] diff --git a/Language/SQL/SimpleSQL/Pretty.lhs b/Language/SQL/SimpleSQL/Pretty.lhs index b48e0b5..c0e86b2 100644 --- a/Language/SQL/SimpleSQL/Pretty.lhs +++ b/Language/SQL/SimpleSQL/Pretty.lhs @@ -87,8 +87,8 @@ > scalarExpr (SpecialOp nm es) = > name nm <+> parens (commaSep $ map scalarExpr es) -> scalarExpr (SpecialOpK (Name nm) fs as) = -> text nm <> parens (sep $ catMaybes +> scalarExpr (SpecialOpK nm fs as) = +> name nm <> parens (sep $ catMaybes > ((fmap scalarExpr fs) > : map (\(n,e) -> Just (text n <+> scalarExpr e)) as)) diff --git a/Language/SQL/SimpleSQL/Syntax.lhs b/Language/SQL/SimpleSQL/Syntax.lhs index 8cfeef2..d461896 100644 --- a/Language/SQL/SimpleSQL/Syntax.lhs +++ b/Language/SQL/SimpleSQL/Syntax.lhs @@ -5,7 +5,7 @@ > ScalarExpr(..) > ,Name(..) > ,TypeName(..) -> ,Duplicates(..) +> ,SetQuantifier(..) > ,SortSpec(..) > ,Direction(..) > ,NullsOrder(..) @@ -65,7 +65,7 @@ > -- order by, to regular function application > | AggregateApp > {aggName :: Name -- ^ aggregate function name -> ,aggDistinct :: Maybe Duplicates -- ^ distinct +> ,aggDistinct :: Maybe SetQuantifier -- ^ distinct > ,aggArgs :: [ScalarExpr]-- ^ args > ,aggOrderBy :: [SortSpec] -- ^ order by > } @@ -192,9 +192,16 @@ > -- t'. > data QueryExpr > = Select -> {qeDuplicates :: Duplicates +> {qeSetQuantifier :: SetQuantifier > ,qeSelectList :: [(Maybe Name,ScalarExpr)] > -- ^ the column aliases and the expressions + +TODO: consider breaking this up. The SQL grammar has +queryexpr = select