diff --git a/Language/SQL/SimpleSQL/Fixity.lhs b/Language/SQL/SimpleSQL/Fixity.lhs index a38741a..f558945 100644 --- a/Language/SQL/SimpleSQL/Fixity.lhs +++ b/Language/SQL/SimpleSQL/Fixity.lhs @@ -117,7 +117,7 @@ the fixity code. > var = HSE.Var . HSE.UnQual . HSE.Ident > sym = HSE.UnQual . HSE.Symbol > name n = case n of -> QName q -> '"' ++ q +> QName q -> '"' : q > Name m -> m > orderExps = map (toHaskell . (\(OrderField a _ _) -> a)) > orderInf = map (\(OrderField _ b c) -> (b,c)) diff --git a/Language/SQL/SimpleSQL/Parser.lhs b/Language/SQL/SimpleSQL/Parser.lhs index 009c0ea..b63bec7 100644 --- a/Language/SQL/SimpleSQL/Parser.lhs +++ b/Language/SQL/SimpleSQL/Parser.lhs @@ -331,7 +331,7 @@ that SQL supports. > where > precision t = try (parens (commaSep integerLiteral)) >>= makeWrap t > makeWrap (TypeName t) [a] = return $ PrecTypeName t a -> makeWrap (TypeName t) [a,b] = return $ Prec2TypeName t a b +> makeWrap (TypeName t) [a,b] = return $ PrecScaleTypeName t a b > makeWrap _ _ = fail "there must be one or two precision components" diff --git a/Language/SQL/SimpleSQL/Pretty.lhs b/Language/SQL/SimpleSQL/Pretty.lhs index 16be481..a6ce889 100644 --- a/Language/SQL/SimpleSQL/Pretty.lhs +++ b/Language/SQL/SimpleSQL/Pretty.lhs @@ -165,7 +165,7 @@ > typeName :: TypeName -> Doc > typeName (TypeName t) = text t > typeName (PrecTypeName t a) = text t <+> parens (text $ show a) -> typeName (Prec2TypeName t a b) = +> typeName (PrecScaleTypeName t a b) = > text t <+> parens (text (show a) <+> comma <+> text (show b)) diff --git a/Language/SQL/SimpleSQL/Syntax.lhs b/Language/SQL/SimpleSQL/Syntax.lhs index fba7565..c81c8e9 100644 --- a/Language/SQL/SimpleSQL/Syntax.lhs +++ b/Language/SQL/SimpleSQL/Syntax.lhs @@ -45,8 +45,7 @@ > -- * 12.34e-6 > NumLit String > -- | string literal, currently only basic strings between -> -- single quotes without escapes (no single quotes in strings -> -- then) +> -- single quotes with a single quote escaped using '' > | StringLit String > -- | text of interval literal, units of interval precision, > -- e.g. interval 3 days (3) @@ -95,9 +94,7 @@ > -- keywords instead of commas to separate the arguments, > -- e.g. substring(t from 1 to 5) > | SpecialOp Name [ScalarExpr] -> -- | case expression. both flavours supported. Multiple -> -- condition when branches not currently supported (case when -> -- a=4,b=5 then x end) +> -- | case expression. both flavours supported > | Case > {caseTest :: Maybe ScalarExpr -- ^ test value > ,caseWhens :: [([ScalarExpr],ScalarExpr)] -- ^ when branches @@ -123,7 +120,7 @@ > -- | Represents a type name, used in casts. > data TypeName = TypeName String > | PrecTypeName String Int -> | Prec2TypeName String Int Int +> | PrecScaleTypeName String Int Int > deriving (Eq,Show,Read) @@ -147,15 +144,17 @@ > | SqAny > deriving (Eq,Show,Read) +> -- | Represents one field in an order by list > data OrderField = OrderField ScalarExpr Direction NullsOrder > deriving (Eq,Show,Read) +> -- | Represents 'nulls first' or 'nulls last' in an order by clause > data NullsOrder = NullsOrderDefault > | NullsFirst > | NullsLast > deriving (Eq,Show,Read) -> -- | Represents the frame clause of a window +> -- | Represents theq frame clause of a window > -- this can be [range | rows] frame_start > -- or [range | rows] between frame_start and frame_end > data Frame = FrameFrom FrameRows FramePos @@ -182,10 +181,10 @@ > -- > -- * a common table expression (with); > -- -> -- * a values expression (not yet supported); +> -- * a values expression; > -- > -- * or the table syntax - 'table t', shorthand for 'select * from -> -- t' (not yet supported). +> -- t'. > data QueryExpr > = Select > {qeDuplicates :: Duplicates @@ -244,6 +243,7 @@ I'm not sure if this is valid syntax or not. > -- | Corresponding, an option for the set operators > data Corresponding = Corresponding | Respectively deriving (Eq,Show,Read) +> -- | Represents an item in a group by clause > data GroupingExpr > = GroupingParens [GroupingExpr] > | Cube [GroupingExpr] diff --git a/tools/Language/SQL/SimpleSQL/ScalarExprs.lhs b/tools/Language/SQL/SimpleSQL/ScalarExprs.lhs index 61dd4f2..611ff2b 100644 --- a/tools/Language/SQL/SimpleSQL/ScalarExprs.lhs +++ b/tools/Language/SQL/SimpleSQL/ScalarExprs.lhs @@ -145,7 +145,7 @@ Tests for parsing scalar expressions > ,Cast (StringLit "1") $ PrecTypeName "float" 8) > ,("cast('1' as decimal(15,2))" -> ,Cast (StringLit "1") $ Prec2TypeName "decimal" 15 2) +> ,Cast (StringLit "1") $ PrecScaleTypeName "decimal" 15 2) > ,("double precision '3'"