From 52b9f3f4f4a411657e52a4f91f9839316b82789e Mon Sep 17 00:00:00 2001
From: Jake Wheat <jakewheatmail@gmail.com>
Date: Fri, 13 Dec 2013 14:21:25 +0200
Subject: [PATCH] add support for count(*)

---
 Parser.lhs | 5 ++++-
 TODO       | 2 ++
 Tests.lhs  | 8 +++++++-
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/Parser.lhs b/Parser.lhs
index f67104f..28f6039 100644
--- a/Parser.lhs
+++ b/Parser.lhs
@@ -71,7 +71,10 @@ to be.
 
 
 > app :: P ScalarExpr
-> app = App <$> identifierString <*> parens (commaSep scalarExpr')
+> app = App <$> identifierString
+>       -- support for count(*)
+>       <*> parens (choice[(:[]) <$> try star
+>                         ,commaSep scalarExpr'])
 
 > scase :: P ScalarExpr
 > scase =
diff --git a/TODO b/TODO
index f311c09..81039ea 100644
--- a/TODO
+++ b/TODO
@@ -14,6 +14,8 @@ position annotation
 
 emacs parse error formatting
 
+haddock
+
 = sql support
 
 count(*)
diff --git a/Tests.lhs b/Tests.lhs
index c77f2d2..ef8bf50 100644
--- a/Tests.lhs
+++ b/Tests.lhs
@@ -199,7 +199,13 @@
 
 > fullQueries :: TestItem
 > fullQueries = Group "queries" $ map (uncurry TestQueryExpr)
->     [("select a, sum(c+d) as s\n\
+>     [("select count(*) from t"
+>      ,makeSelect
+>       {qeSelectList = [(Nothing, App "count" [Star])]
+>       ,qeFrom = [SimpleTableRef "t"]
+>       }
+>      )
+>     ,("select a, sum(c+d) as s\n\
 >       \  from t,u\n\
 >       \  where a > 5\n\
 >       \  group by a\n\