diff --git a/Language/SQL/SimpleSQL/Parser.lhs b/Language/SQL/SimpleSQL/Parser.lhs index e99090a..cfc7e76 100644 --- a/Language/SQL/SimpleSQL/Parser.lhs +++ b/Language/SQL/SimpleSQL/Parser.lhs @@ -1,7 +1,3 @@ -TODO: -P -> P.Parser -swap order in select items - > {-# LANGUAGE TupleSections #-} > -- | This is the module with the parser functions. > module Language.SQL.SimpleSQL.Parser @@ -573,11 +569,11 @@ expose the b expression for window frame clause range between == select lists -> selectItem :: Parser (Maybe Name, ValueExpr) -> selectItem = flip (,) <$> valueExpr <*> optionMaybe (try als) +> selectItem :: Parser (ValueExpr,Maybe Name) +> selectItem = (,) <$> valueExpr <*> optionMaybe (try als) > where als = optional (try (keyword_ "as")) *> name -> selectList :: Parser [(Maybe Name,ValueExpr)] +> selectList :: Parser [(ValueExpr,Maybe Name)] > selectList = commaSep1 selectItem == from diff --git a/Language/SQL/SimpleSQL/Pretty.lhs b/Language/SQL/SimpleSQL/Pretty.lhs index cb4409e..4c8542c 100644 --- a/Language/SQL/SimpleSQL/Pretty.lhs +++ b/Language/SQL/SimpleSQL/Pretty.lhs @@ -213,10 +213,10 @@ > text "as" <+> name nm > <+> maybe empty (parens . commaSep . map name) cols -> selectList :: [(Maybe Name, ValueExpr)] -> Doc +> selectList :: [(ValueExpr,Maybe Name)] -> Doc > selectList is = commaSep $ map si is > where -> si (al,e) = valueExpr e <+> maybe empty als al +> si (e,al) = valueExpr e <+> maybe empty als al > als al = text "as" <+> name al > from :: [TableRef] -> Doc diff --git a/Language/SQL/SimpleSQL/Syntax.lhs b/Language/SQL/SimpleSQL/Syntax.lhs index 3e3d0e2..0015c71 100644 --- a/Language/SQL/SimpleSQL/Syntax.lhs +++ b/Language/SQL/SimpleSQL/Syntax.lhs @@ -196,8 +196,8 @@ > data QueryExpr > = Select > {qeSetQuantifier :: SetQuantifier -> ,qeSelectList :: [(Maybe Name,ValueExpr)] -> -- ^ the column aliases and the expressions +> ,qeSelectList :: [(ValueExpr,Maybe Name)] +> -- ^ the expressions and the column aliases TODO: consider breaking this up. The SQL grammar has queryexpr = select