Keep old behavior of update
This commit is contained in:
parent
6a13bde01b
commit
d1d5f84b22
1 changed files with 4 additions and 5 deletions
|
@ -68,7 +68,7 @@ import Control.Concurrent.MVar.Lifted (MVar, newMVar, addMVarFinalizer,
|
||||||
#endif
|
#endif
|
||||||
import Control.Applicative ((<$>))
|
import Control.Applicative ((<$>))
|
||||||
import Control.Exception (catch)
|
import Control.Exception (catch)
|
||||||
import Control.Monad (when)
|
import Control.Monad (when, void)
|
||||||
import Control.Monad.Base (MonadBase)
|
import Control.Monad.Base (MonadBase)
|
||||||
import Control.Monad.Error (Error(..))
|
import Control.Monad.Error (Error(..))
|
||||||
import Control.Monad.Reader (MonadReader, ReaderT, runReaderT, ask, asks, local)
|
import Control.Monad.Reader (MonadReader, ReaderT, runReaderT, ask, asks, local)
|
||||||
|
@ -618,10 +618,9 @@ update :: (MonadIO m)
|
||||||
=> [UpdateOption] -> Selection -> Document -> Action m ()
|
=> [UpdateOption] -> Selection -> Document -> Action m ()
|
||||||
-- ^ Update first document in selection using updater document, unless 'MultiUpdate' option is supplied then update all documents in selection. If 'Upsert' option is supplied then treat updater as document and insert it if selection is empty.
|
-- ^ Update first document in selection using updater document, unless 'MultiUpdate' option is supplied then update all documents in selection. If 'Upsert' option is supplied then treat updater as document and insert it if selection is empty.
|
||||||
update opts (Select sel col) up = do
|
update opts (Select sel col) up = do
|
||||||
res <- update' True col [(sel, up, opts)]
|
db <- thisDatabase
|
||||||
if not $ null $ writeErrors res
|
ctx <- ask
|
||||||
then liftIO $ throwIO $ WriteFailure 0 0 (show $ head $ writeErrors res)
|
liftIO $ runReaderT (void $ write (Update (db <.> col) opts sel up)) ctx
|
||||||
else return ()
|
|
||||||
|
|
||||||
updateCommandDocument :: Collection -> Bool -> [Document] -> Document -> Document
|
updateCommandDocument :: Collection -> Bool -> [Document] -> Document -> Document
|
||||||
updateCommandDocument col ordered updates writeConcern =
|
updateCommandDocument col ordered updates writeConcern =
|
||||||
|
|
Loading…
Reference in a new issue