1
Fork 0

swap order in select lists so the expression comes first then the alias to match the order in the concrete syntax

This commit is contained in:
Jake Wheat 2013-12-31 11:31:00 +02:00
parent 552d3f5383
commit 7cf5275615
9 changed files with 43 additions and 46 deletions
Language/SQL/SimpleSQL

View file

@ -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

View file

@ -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

View file

@ -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 <select list> [<table expression>]