From 4244f56ce6c7044a1ce096843eb991856422c0cc Mon Sep 17 00:00:00 2001 From: Jim Menard Date: Tue, 2 Dec 2008 10:25:36 -0500 Subject: [PATCH] Fixed bug in BSON serializer: was forgetting to include NUL byt in string length. --- lib/mongo/util/bson.rb | 2 +- tests/test_db_api.rb | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/mongo/util/bson.rb b/lib/mongo/util/bson.rb index 07d2bed..2b3ba93 100644 --- a/lib/mongo/util/bson.rb +++ b/lib/mongo/util/bson.rb @@ -213,7 +213,7 @@ class BSON end_pos = buf.position # Put the string size in front - buf.put_int(end_pos - start_pos - 1, len_pos) + buf.put_int(end_pos - start_pos, len_pos) # Go back to where we were buf.position = end_pos diff --git a/tests/test_db_api.rb b/tests/test_db_api.rb index 4e75118..e2b4f08 100644 --- a/tests/test_db_api.rb +++ b/tests/test_db_api.rb @@ -72,9 +72,7 @@ class DBAPITest < Test::Unit::TestCase assert rows.length >= 1 row = rows.detect { |r| r['name'] == @coll_full_name } assert_not_nil row -# FIXME restore this test when Mongo fixes this bug (or we prove I'm doing something wrong) - # Mongo bug: returns string with wrong length, so last byte of value is chopped off. -# assert_equal @coll.name, row['options']['create'] + assert_equal @coll.name, row['options']['create'] end def test_full_coll_name