diff --git a/test/Test.hs b/test/Test.hs index 98bb975..2acc9c6 100644 --- a/test/Test.hs +++ b/test/Test.hs @@ -238,6 +238,28 @@ main = do , (p4e, f42, p2e) , (p2e, f21, p1e) ] + it "works for a many-to-many explicit join" $ + run $ do + p1e@(Entity p1k _) <- insert' p1 + p2e@(Entity p2k _) <- insert' p2 + _ <- insert' p3 + p4e@(Entity p4k _) <- insert' p4 + f12 <- insert' (Follow p1k p2k) + f21 <- insert' (Follow p2k p1k) + f42 <- insert' (Follow p4k p2k) + f11 <- insert' (Follow p1k p1k) + ret <- select $ + from $ \(follower `InnerJoin` follows `InnerJoin` followed) -> do + on $ followed ^. PersonId ==. follows ^. FollowFollowed + on $ follower ^. PersonId ==. follows ^. FollowFollower + orderBy [ asc (follower ^. PersonName) + , asc (followed ^. PersonName) ] + return (follower, follows, followed) + liftIO $ ret `shouldBe` [ (p1e, f11, p1e) + , (p1e, f12, p2e) + , (p4e, f42, p2e) + , (p2e, f21, p1e) ] + describe "select/orderBy" $ do it "works with a single ASC field" $