I encountered a bug in skip parameter and nextBatch function: skip does not have any effect, nextBatch causes internal error with fromJust.
Example function which breaks with bug:
findAll :: Query -> Action IO [Document]
findAll q = go 0
where
pageSize :: Word32
pageSize = 1
go :: Word32 -> Action IO [Document]
go offset = do
cc <- find q { sort = [ "_id" =: 1 ], skip = offset, limit = pageSize, batchSize = pageSize }
batch <- rest cc
liftIO $ putStrLn $ "Data: +" <> show ( length batch ) <> " to " <> show offset
mapM_ (\x -> liftIO $ print $ docId x ) batch
if length batch < fromIntegral pageSize || offset >= 10 {-So we will not run infinitely with bug-}
then return batch
else (batch ++) <$> go (offset + pageSize )
It iterates over same item (infinitely in normal scenario).
Spent 3 hours realizing the bug is not in my code, and 10 minutes slopping a fix, which itself seems trivial. Detailed AI-generated description is in BUG.md.
I encountered a bug in
skipparameter andnextBatchfunction:skipdoes not have any effect,nextBatchcauses internal error withfromJust.Example function which breaks with bug:
It iterates over same item (infinitely in normal scenario).
Spent 3 hours realizing the bug is not in my code, and 10 minutes slopping a fix, which itself seems trivial. Detailed AI-generated description is in BUG.md.