Commits

spin  committed 2e7d6b3

Fix for couchPutRev

  • Participants
  • Parent commits e1d8033

Comments (0)

Files changed (3)

File src/Database/CouchDB/Enumerator.hs

      -> HT.Query    -- ^ Query arguments.
      -> a           -- ^ The object to store.
      -> m Revision   
-couchPutRev p r q val = do 
-    v <- run_ $ couch' HT.methodPut p [("If-Match", TE.encodeUtf8 r)] q 
+couchPutRev p r q val = do
+    liftIO $ print $ TE.encodeUtf8 r
+    v <- run_ $ couch' HT.methodPut p (ifMatch r) q 
             (\_ -> iterParser A.json) body
     either (liftIO . throw) return (valToObj v >>= objToRev)
   where 
     body = jsonToReqBody val
+    ifMatch "" = []
+    ifMatch rv = [("If-Match", TE.encodeUtf8 rv)]
     
 -- | A version of 'couchPut' which ignores the return value. This is slightly 
 --   faster than / _ <- couchPut .../ since the JSON parser is not run.

File test/Database/CouchDB/Enumerator/Test/Generic.hs

     simpleStr :: ByteString
 } deriving (Show, Eq, Data, Typeable)
 
--- | Just put and get doc
-case_simpleGeneric :: Assertion
-case_simpleGeneric = runCouch "localhost" 5984 "testcouchdbenum" $ do
-    rev <- E.catch (couchRev "gen_doc")
-        (\(_ :: CouchError) -> return "") 
---    liftIO $ print rev
---    couchDelete "gen_doc3" $ fromJust rev        
-    _ <- CG.couchPut "gen_doc" rev [] genDoc 
-    r <- CG.couchGet "gen_doc" []
-    liftIO $ print (r :: CG.CouchDoc SimpleDoc)
-    return ()
-    
 case_forsed :: Assertion
 case_forsed = runCouch "localhost" 5984 "testcouchdbenum" $ do
+    couchPutDb ""
     r <- CG.couchPut' "gen_doc" [] genDoc 
     liftIO $ print r
     return ()

File test/Main.hs

 
 import qualified Database.CouchDB.Enumerator.Test.Basic
 import qualified Database.CouchDB.Enumerator.Test.View
+import qualified Database.CouchDB.Enumerator.Test.Generic
 
 main :: IO ()
 main = defaultMain tests
 tests = [
       Database.CouchDB.Enumerator.Test.Basic.tests
     , Database.CouchDB.Enumerator.Test.View.tests
---        Database.CouchDB.Enumerator.Test.Generic.tests 
+    , Database.CouchDB.Enumerator.Test.Generic.tests 
     ]