diff --git a/src/Database/Esqueleto/Internal/Language.hs b/src/Database/Esqueleto/Internal/Language.hs index ca461ef..72f1341 100644 --- a/src/Database/Esqueleto/Internal/Language.hs +++ b/src/Database/Esqueleto/Internal/Language.hs @@ -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. diff --git a/test/Test.hs b/test/Test.hs index a6184b7..3026730 100644 --- a/test/Test.hs +++ b/test/Test.hs @@ -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 ]