From 8df947c7042dcc4af28969d6c660ec0982e1a31e Mon Sep 17 00:00:00 2001 From: "Scott R. Parish" Date: Sun, 14 Mar 2010 13:25:44 -0500 Subject: [PATCH] 8e035fded4 missed the Put side --- Database/MongoDB/BSON.hs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Database/MongoDB/BSON.hs b/Database/MongoDB/BSON.hs index d51bcb9..93366a1 100644 --- a/Database/MongoDB/BSON.hs +++ b/Database/MongoDB/BSON.hs @@ -294,10 +294,11 @@ putVal (BsonDoc o) = putObj o putVal (BsonArray es) = putOutterObj bs where bs = runPut $ forM_ (List.zip [(0::Int) .. ] es) $ \(i, e) -> putType e >> putS (L8.fromString $ show i) >> putVal e -putVal (BsonBinary t bs)= do putI32 $ fromIntegral $ 4 + L.length bs - putI8 $ fromBinarySubType t - putI32 $ fromIntegral $ L.length bs - putLazyByteString bs +putVal (BsonBinary t bs) = do + putI32 $ fromIntegral $ (if t == BSTByteArray then 4 else 0) + L.length bs + putI8 $ fromBinarySubType t + when (t == BSTByteArray) $ putI32 $ fromIntegral $ L.length bs + putLazyByteString bs putVal BsonUndefined = putNothing putVal (BsonObjectId o) = putWord64be (fromIntegral $ o `shiftR` 32) >> putWord32be (fromIntegral $ o .&. 0xffffffff)