From 8ebb87792a93f9cbfeddb548512f7fd94fdce29a Mon Sep 17 00:00:00 2001 From: Thijs Cadier Date: Sun, 23 Aug 2015 10:31:06 +0200 Subject: [PATCH] Add test for multiple queries with same fields object --- src/collection.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/collection.rs b/src/collection.rs index 1851fcc..d510029 100644 --- a/src/collection.rs +++ b/src/collection.rs @@ -496,6 +496,13 @@ mod tests { fields: Some(fields), read_prefs: None }; + + // Query a couple of times to make sure the C driver keeps + // access to the fields bson object. + for _ in 0..5 { + collection.find(&query, Some(&options)).unwrap(); + } + let mut cursor = collection.find(&query, Some(&options)).unwrap(); let next_document = cursor.next().unwrap().unwrap(); assert!(next_document.contains_key("key_1"));