From f056f8808822af7e832a9a19f1acded196b8629a Mon Sep 17 00:00:00 2001 From: Alberto Valverde Date: Fri, 10 Apr 2015 10:33:24 +0200 Subject: [PATCH] added test for 48cae53 --- test/Test.hs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/test/Test.hs b/test/Test.hs index 09b862d..fd58f93 100644 --- a/test/Test.hs +++ b/test/Test.hs @@ -74,6 +74,10 @@ share [mkPersist sqlSettings, mkMigrate "migrateAll"] [persistUpperCase| frontcoverNumber Int Foreign Frontcover fkfrontcover frontcoverNumber deriving Eq Show + Tag + name String + Primary name + deriving Eq Show Article2 title String frontcoverId FrontcoverId @@ -256,13 +260,24 @@ main = do run $ do let fc = Frontcover number "" number = 101 - Right thePk = keyFromValues [PersistInt64 $ fromIntegral number] + Right thePk = keyFromValues [toPersistValue number] fcPk <- insert fc [Entity _ ret] <- select $ from $ return liftIO $ do ret `shouldBe` fc fcPk `shouldBe` thePk + it "works when returning a custom non-composite primary key from a query" $ + run $ do + let name = "foo" + t = Tag name + Right thePk = keyFromValues [toPersistValue name] + tagPk <- insert t + [Value ret] <- select $ from $ \t' -> return (t'^.TagId) + liftIO $ do + ret `shouldBe` thePk + thePk `shouldBe` tagPk + it "works when returning a composite primary key from a query" $ pendingWith "Need to refactor 'Value a's SqlQuery instance" {-