diff --git a/Language/SQL/SimpleSQL/Parser.lhs b/Language/SQL/SimpleSQL/Parser.lhs index 5811ecc..f88c3e2 100644 --- a/Language/SQL/SimpleSQL/Parser.lhs +++ b/Language/SQL/SimpleSQL/Parser.lhs @@ -302,10 +302,14 @@ that SQL supports. > <$ try (keyword_ "character" <* keyword_ "varying") > ,TypeName <$> identifierString] -== scalar parens +== scalar parens and row ctor > sparens :: P ScalarExpr -> sparens = Parens <$> parens scalarExpr' +> sparens = +> ctor <$> parens (commaSep1 scalarExpr') +> where +> ctor [a] = Parens a +> ctor as = SpecialOp (Name "rowctor") as == operator parsing diff --git a/Language/SQL/SimpleSQL/Pretty.lhs b/Language/SQL/SimpleSQL/Pretty.lhs index bc40e19..9e7239f 100644 --- a/Language/SQL/SimpleSQL/Pretty.lhs +++ b/Language/SQL/SimpleSQL/Pretty.lhs @@ -80,6 +80,9 @@ > <+> text "for" > <+> scalarExpr e) +> scalarExpr (SpecialOp (Name "rowctor") as) = +> parens $ commaSep $ map scalarExpr as + > scalarExpr (SpecialOp nm es) = > name nm <+> parens (commaSep $ map scalarExpr es) diff --git a/tools/Language/SQL/SimpleSQL/ScalarExprs.lhs b/tools/Language/SQL/SimpleSQL/ScalarExprs.lhs index b4fae0d..fec0790 100644 --- a/tools/Language/SQL/SimpleSQL/ScalarExprs.lhs +++ b/tools/Language/SQL/SimpleSQL/ScalarExprs.lhs @@ -203,6 +203,9 @@ Tests for parsing scalar expressions > ,("substring(x from 1 for 2)" > ,SpecialOp "substring" [Iden "x", NumLit "1", NumLit "2"]) +> ,("(1,2)" +> ,SpecialOp "rowctor" [NumLit "1", NumLit "2"]) + > ] > aggregates :: TestItem