Explicitly state multiple 'orderBy's work (closes #103).

This commit is contained in:
Felipe Lessa 2015-06-20 23:50:47 -03:00
parent 80beea1e67
commit 29eb0d8be3
2 changed files with 7 additions and 3 deletions

View File

@ -166,6 +166,9 @@ class (Functor query, Applicative query, Monad query) =>
groupBy :: (ToSomeValues expr a) => a -> query ()
-- | @ORDER BY@ clause. See also 'asc' and 'desc'.
--
-- Multiple calls to 'orderBy' get concatenated on the final
-- query, including 'distinctOnOrderBy'.
orderBy :: [expr OrderBy] -> query ()
-- | Ascending order of this field or expression.

View File

@ -706,7 +706,7 @@ main = do
return p
liftIO $ ret `shouldBe` [ p1e, p3e, p2e ]
it "works with two ASC fields" $
it "works with two ASC fields (one call)" $
run $ do
p1e <- insert' p1
p2e <- insert' p2
@ -724,7 +724,7 @@ main = do
liftIO $ ret `shouldBe` [ p2e, p4e, p3e, p1e ]
#endif
it "works with one ASC and one DESC field" $
it "works with one ASC and one DESC field (two calls)" $
run $ do
p1e <- insert' p1
p2e <- insert' p2
@ -732,7 +732,8 @@ main = do
p4e <- insert' p4
ret <- select $
from $ \p -> do
orderBy [desc (p ^. PersonAge), asc (p ^. PersonName)]
orderBy [desc (p ^. PersonAge)]
orderBy [asc (p ^. PersonName)]
return p
#ifdef WITH_POSTGRESQL
liftIO $ ret `shouldBe` [ p2e, p1e, p4e, p3e ]