Fix INT / LONG serialization

This commit is contained in:
Kyle Banker 2010-10-01 14:56:31 -04:00
parent c04dfec1db
commit 51964f8ad5
3 changed files with 6 additions and 2 deletions

Binary file not shown.

View File

@ -226,8 +226,12 @@ public class RubyBSONEncoder extends BSONEncoder {
if ( val instanceof String )
putString(name, val.toString() );
else if ( val instanceof Number )
putNumber(name, (Number)val);
else if ( val instanceof Number ) {
if (((Number)val).longValue() >= Integer.MIN_VALUE && ((Number)val).longValue() <= Integer.MAX_VALUE)
putNumber(name, ((Number)val).intValue() );
else
putNumber(name, (Number)val );
}
else if ( val instanceof Boolean )
putBoolean(name, (Boolean)val);