RUBY-244 issue serializing Time in array
This commit is contained in:
parent
e5338316c8
commit
2b7739a257
Binary file not shown.
@ -281,6 +281,9 @@ public class RubyBSONEncoder extends BSONEncoder {
|
|||||||
else if ( val instanceof Iterable)
|
else if ( val instanceof Iterable)
|
||||||
putIterable( name , (Iterable)val );
|
putIterable( name , (Iterable)val );
|
||||||
|
|
||||||
|
else if ( val instanceof Date )
|
||||||
|
putDate( name , ((Date)val).getTime() );
|
||||||
|
|
||||||
else if ( val instanceof byte[] )
|
else if ( val instanceof byte[] )
|
||||||
putBinary( name , (byte[])val );
|
putBinary( name , (byte[])val );
|
||||||
|
|
||||||
|
@ -246,8 +246,14 @@ class BSONTest < Test::Unit::TestCase
|
|||||||
assert_in_delta doc['date'], doc2['date'], 0.001
|
assert_in_delta doc['date'], doc2['date'], 0.001
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_date_in_array
|
||||||
|
doc = {'date' => [Time.now.utc]}
|
||||||
|
bson = @encoder.serialize(doc)
|
||||||
|
doc2 = @encoder.deserialize(bson)
|
||||||
|
end
|
||||||
|
|
||||||
def test_date_returns_as_utc
|
def test_date_returns_as_utc
|
||||||
doc = {'date' => Time.now}
|
doc = {'date' => Time.now.utc}
|
||||||
bson = @encoder.serialize(doc)
|
bson = @encoder.serialize(doc)
|
||||||
doc2 = @encoder.deserialize(bson)
|
doc2 = @encoder.deserialize(bson)
|
||||||
assert doc2['date'].utc?
|
assert doc2['date'].utc?
|
||||||
|
Loading…
Reference in New Issue
Block a user