packages feed

persistent-mongoDB 0.7.0 → 0.8.0

raw patch · 2 files changed

+33/−29 lines, 2 filesdep ~conduitdep ~persistent

Dependency ranges changed: conduit, persistent

Files

Database/Persist/MongoDB.hs view
@@ -159,10 +159,10 @@   (map u (map (T.unpack . unDBName . snd) $ persistUniqueToFieldNames uniq))   (map DB.val (persistUniqueToValues uniq)) -pairFromDocument :: PersistEntity val+pairFromDocument :: (PersistEntity val, PersistEntityBackend val ~ DB.Action)                  => EntityDef                  -> [DB.Field]-                 -> Either String (Entity DB.Action val)+                 -> Either String (Entity val) pairFromDocument ent document = pairFromPersistValues document   where     pairFromPersistValues (x:xs) =@@ -278,20 +278,22 @@         query = DB.select (filtersToSelector filts) (u $ T.unpack $ unDBName $ entityDB t)         t = entityDef $ dummyFromFilts filts -    selectSource filts opts = C.Source $ do-        cursor <- lift $ DB.find $ makeQuery filts opts-        return $ C.PreparedSource-            { C.sourcePull = lift $ do-                mdoc <- DB.next cursor-                case mdoc of-                    Nothing -> return C.Closed-                    Just doc ->-                        case pairFromDocument t doc of-                            Left s -> liftIO $ throwIO $ PersistMarshalError $ T.pack s-                            Right row -> return $ C.Open row-            , C.sourceClose = return ()-            }+    selectSource filts opts = C.Source+        { C.sourcePull = do+            cursor <- lift $ DB.find $ makeQuery filts opts+            pull cursor+        , C.sourceClose = return ()+        }       where+        mkSrc cursor = C.Source (pull cursor) (return ())+        pull cursor = lift $ do+            mdoc <- DB.next cursor+            case mdoc of+                Nothing -> return C.Closed+                Just doc ->+                    case pairFromDocument t doc of+                        Left s -> liftIO $ throwIO $ PersistMarshalError $ T.pack s+                        Right row -> return $ C.Open (mkSrc cursor) row         t = entityDef $ dummyFromFilts filts      selectFirst filts opts = do@@ -304,18 +306,20 @@       where         t = entityDef $ dummyFromFilts filts -    selectKeys filts = C.Source $ do-        cursor <- lift $ DB.find query-        return $ C.PreparedSource-            { C.sourcePull = lift $ do-                mdoc <- DB.next cursor-                case mdoc of-                    Nothing -> return C.Closed-                    Just [_ DB.:= DB.ObjId oid] -> return $ C.Open $ oidToKey oid-                    Just y -> liftIO $ throwIO $ PersistMarshalError $ T.pack $ "Unexpected in selectKeys: " ++ show y-            , C.sourceClose = return ()-            }+    selectKeys filts = C.Source+        { C.sourcePull = do+            cursor <- lift $ DB.find query+            pull cursor+        , C.sourceClose = return ()+        }       where+        mkSrc cursor = C.Source (pull cursor) (return ())+        pull cursor = lift $ do+            mdoc <- DB.next cursor+            case mdoc of+                Nothing -> return C.Closed+                Just [_ DB.:= DB.ObjId oid] -> return $ C.Open (mkSrc cursor) $ oidToKey oid+                Just y -> liftIO $ throwIO $ PersistMarshalError $ T.pack $ "Unexpected in selectKeys: " ++ show y         query = (DB.select (filtersToSelector filts) (u $ T.unpack $ unDBName $ entityDB t)) {           DB.project = [u"_id" DB.=: (1 :: Int)]         }
persistent-mongoDB.cabal view
@@ -1,5 +1,5 @@ name:            persistent-mongoDB-version:         0.7.0+version:         0.8.0 license:         BSD3 license-file:    LICENSE author:          Greg Weber <greg@gregweber.info>@@ -14,12 +14,12 @@  library     build-depends:   base               >= 4 && < 5-                   , persistent         >= 0.7     && < 0.8+                   , persistent         >= 0.8     && < 0.9                    , text               >= 0.8     && < 1                    , transformers       >= 0.2.1   && < 0.3                    , containers         >= 0.2     && < 0.5                    , bytestring         >= 0.9     && < 0.10-                   , conduit+                   , conduit            >= 0.2                    , mongoDB            >= 1.2     && < 1.3                    , bson               >= 0.1.6                    , network            >= 2.2.1.7 && < 3