From e22f2326e62391c952c6f146b7b45fc2e4c67c60 Mon Sep 17 00:00:00 2001 From: Alberto Valverde Date: Tue, 23 Dec 2014 11:53:19 +0100 Subject: [PATCH] Added failing test case for custom primary keys (#87) --- test/Test.hs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/Test.hs b/test/Test.hs index ce9cecf..41ba06f 100644 --- a/test/Test.hs +++ b/test/Test.hs @@ -59,6 +59,10 @@ share [mkPersist sqlSettings, mkMigrate "migrateAll"] [persistUpperCase| follower PersonId followed PersonId deriving Eq Show + Frontcover + number Int + Primary number + deriving Eq Show |] -- | this could be achieved with S.fromList, but not all lists @@ -909,6 +913,16 @@ main = do liftIO $ ret `shouldBe` [ Value (3) ] + it "works with custom primary key" $ + run $ do + let fc = Frontcover number + number = 101 + Right thePk = keyFromValues [PersistInt64 $ fromIntegral number] + fcPk <- insert fc + [Entity _ ret] <- select $ from $ return + liftIO $ do + ret `shouldBe` fc + fcPk `shouldBe` thePk ----------------------------------------------------------------------