packages feed

persistent-mongoDB 2.0.6 → 2.0.7

raw patch · 2 files changed

+22/−16 lines, 2 filesdep ~persistent

Dependency ranges changed: persistent

Files

Database/Persist/MongoDB.hs view
@@ -48,7 +48,7 @@      -- ** Updates     -- $updates-    , nestSet, nestInc, nestDec, nestMul, push+    , nestSet, nestInc, nestDec, nestMul, push, pull, addToSet      -- * Key conversion helpers     , BackendKey(..)@@ -110,6 +110,7 @@ import qualified Control.Monad.IO.Class as Trans import Control.Exception (throw, throwIO) import Data.Acquire (mkAcquire)+import qualified Data.Traversable as Traversable  import Data.Bson (ObjectId(..)) import qualified Database.MongoDB as DB@@ -387,7 +388,9 @@         -- Obviously this could be supported for floats by multiplying with 1/x         (Divide, _)   -> throw $ PersistMongoDBUnsupported "divide not supported"         (BackendSpecificUpdate op, x) -> case op of-            "$push" -> ("$push", DB.val x)+            "$push"     -> ("$push",     DB.val x)+            "$pull"     -> ("$pull",     DB.val x)+            "$addToSet" -> ("$addToSet", DB.val x)             bsup    -> throw $ PersistMongoDBError $ T.pack $ "did not expect BackendSpecificUpdate " ++ T.unpack bsup  updateToMongoField :: (PersistEntity record, PersistEntityBackend record ~ DB.MongoContext)@@ -656,7 +659,7 @@     -- and explicitly closes the cursor when done     selectSourceRes filts opts = do         context <- ask-        return (pull context `fmap` mkAcquire (open context) (close context))+        return (pullCursor context `fmap` mkAcquire (open context) (close context))       where         close :: DB.MongoContext -> DB.Cursor -> IO ()         close context cursor = runReaderT (DB.closeCursor cursor) context@@ -666,22 +669,19 @@                    { DB.snapshot = noSort                    , DB.options = [DB.NoCursorTimeout]                    })-        pull context cursor = do+        pullCursor context cursor = do             mdoc <- liftIO $ runReaderT (DB.nextBatch cursor) context             case mdoc of                 [] -> return ()                 docs -> do                     forM_ docs $ fromPersistValuesThrow t >=> yield-                    pull context cursor+                    pullCursor context cursor         t = entityDef $ Just $ dummyFromFilts filts         (_, _, orders) = limitOffsetOrder opts         noSort = null orders -    selectFirst filts opts = do-        mdoc <- DB.findOne $ makeQuery filts opts-        case mdoc of-            Nothing -> return Nothing-            Just doc -> liftM Just $ fromPersistValuesThrow t doc+    selectFirst filts opts = DB.findOne (makeQuery filts opts)+                         >>= Traversable.mapM (fromPersistValuesThrow t)       where         t = entityDef $ Just $ dummyFromFilts filts @@ -691,17 +691,17 @@                 cursor <- liftIO $ flip runReaderT context $ DB.find $ (makeQuery filts opts) {                     DB.project = [id_ DB.=: (1 :: Int)]                   }-                pull context cursor+                pullCursor context cursor         return $ return make       where-        pull context cursor = do+        pullCursor context cursor = do             mdoc <- liftIO $ runReaderT (DB.next cursor) context             case mdoc of                 Nothing -> return ()                 Just [_id DB.:= idVal] -> do                     k <- liftIO $ keyFrom_idEx idVal                     yield k-                    pull context cursor+                    pullCursor context cursor                 Just y -> liftIO $ throwIO $ PersistMarshalError $ T.pack $ "Unexpected in selectKeys: " ++ show y  orderClause :: PersistEntity val => SelectOpt val -> DB.Field@@ -1275,6 +1275,8 @@  infixr 4 `nestSet` infixr 4 `push`+infixr 4 `pull`+infixr 4 `addToSet`  -- | The normal Persistent equality test '==.' is not generic enough. -- Instead use this with the drill-down arrow operaters such as '->.'@@ -1349,12 +1351,16 @@ nestDec = nestedUpdateOp Subtract nestMul = nestedUpdateOp Multiply -push :: forall record typ.+push, pull, addToSet :: forall record typ.         ( PersistField typ         , PersistEntityBackend record ~ DB.MongoContext         ) => EntityField record [typ] -> typ -> Update record fld `push` val = BackendUpdate $     ArrayUpdate fld $ PersistUpdateOperator val (BackendSpecificUpdate "$push")+fld `pull` val = BackendUpdate $+    ArrayUpdate fld $ PersistUpdateOperator val (BackendSpecificUpdate "$pull")+fld `addToSet` val = BackendUpdate $+    ArrayUpdate fld $ PersistUpdateOperator val (BackendSpecificUpdate "$addToSet")  nestedUpdateOp :: forall record typ.        ( PersistField typ
persistent-mongoDB.cabal view
@@ -1,5 +1,5 @@ name:            persistent-mongoDB-version:         2.0.6+version:         2.0.7 license:         MIT license-file:    LICENSE author:          Greg Weber <greg@gregweber.info>@@ -19,7 +19,7 @@  library     build-depends:   base               >= 4 && < 5-                   , persistent         >= 2.0.5.1 && < 2.1+                   , persistent         >= 2.0.7 && < 2.1                    , text               >= 0.8                    , transformers       >= 0.2.1                    , containers         >= 0.2