Permalink
Browse files

add test case for incrementig a null

  • Loading branch information...
1 parent 791fb19 commit 33a630fe87dd34790aa7b830a825f683d808887b @gregwebs gregwebs committed Apr 8, 2012
Showing with 16 additions and 0 deletions.
  1. +16 −0 persistent-test/PersistentTest.hs
View
16 persistent-test/PersistentTest.hs
@@ -98,6 +98,9 @@ share [mkPersist sqlSettings, mkMigrate "testMigrate", mkDeleteCascade] [persis
-- Indented comment
name String
age Int
+ PersonMaybeAge
+ name String
+ age Int Maybe
Pet no-json
ownerId PersonId
name String
@@ -399,6 +402,19 @@ specs = describe "persistent" $ do
Just pBlue30 <- get key25
pBlue30 @== Person "Updated" 30 Nothing
+ it "maybe update" $ db $ do
+ let noAge = PersonMaybeAge "Michael" Nothing
+ keyNoAge <- insert noAge
+ update keyNoAge [PersonMaybeAgeAge +=. Just 2]
+ Just noAge2 <- get keyNoAge
+ -- the correct answer is very debatable
+#ifdef WITH_MONGODB
+ personMaybeAgeAge noAge2 @== Just 2
+#else
+ personMaybeAgeAge noAge2 @== Nothing
+#endif
+
+
it "updateWhere" $ db $ do
let p1 = Person "Michael" 25 Nothing

0 comments on commit 33a630f

Please sign in to comment.