Skip to content

Commit

Permalink
Remove deprecated mongo snapshot query option
Browse files Browse the repository at this point in the history
This flag was deprecated since Mongo Server 3.7.4.
Its presence in queries produce failures in the mongoDB driver when
interfacing against Mongo Servers >= version 6.0.
  • Loading branch information
darycabrera committed Aug 26, 2024
1 parent 40ed447 commit c6fd4cb
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions persistent-mongoDB/Database/Persist/MongoDB.hs
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,6 @@ instance PersistQueryRead DB.MongoContext where
pure (cnt > 0)

-- | uses cursor option NoCursorTimeout
-- If there is no sorting, it will turn the $snapshot option on
-- and explicitly closes the cursor when done
selectSourceRes filts opts = do
context <- ask
Expand All @@ -732,9 +731,7 @@ instance PersistQueryRead DB.MongoContext where
close context cursor = runReaderT (DB.closeCursor cursor) context
open :: DB.MongoContext -> IO DB.Cursor
open = runReaderT (DB.find (makeQuery filts opts)
-- it is an error to apply $snapshot when sorting
{ DB.snapshot = noSort
, DB.options = [DB.NoCursorTimeout]
{ DB.options = [DB.NoCursorTimeout]
})
pullCursor context cursor = do
mdoc <- liftIO $ runReaderT (DB.nextBatch cursor) context
Expand All @@ -744,8 +741,6 @@ instance PersistQueryRead DB.MongoContext where
forM_ docs $ fromPersistValuesThrow t >=> yield
pullCursor context cursor
t = entityDef $ Just $ dummyFromFilts filts
(_, _, orders) = limitOffsetOrder opts
noSort = null orders

selectFirst filts opts = DB.findOne (makeQuery filts opts)
>>= Traversable.mapM (fromPersistValuesThrow t)
Expand Down

0 comments on commit c6fd4cb

Please sign in to comment.