RUBY-139 Use BSON binary subtype 0 by default
This commit is contained in:
parent
3509926071
commit
db1213fc5d
@ -43,7 +43,7 @@ module BSON
|
|||||||
# SUBTYPE_BYTES, SUBTYPE_UUID, SUBTYPE_MD5, and SUBTYPE_USER_DEFINED.
|
# SUBTYPE_BYTES, SUBTYPE_UUID, SUBTYPE_MD5, and SUBTYPE_USER_DEFINED.
|
||||||
#
|
#
|
||||||
# @see http://www.mongodb.org/display/DOCS/BSON#BSON-noteondatabinary BSON binary subtypes.
|
# @see http://www.mongodb.org/display/DOCS/BSON#BSON-noteondatabinary BSON binary subtypes.
|
||||||
def initialize(data=[], subtype=SUBTYPE_BYTES)
|
def initialize(data=[], subtype=SUBTYPE_SIMPLE)
|
||||||
super(data)
|
super(data)
|
||||||
@subtype = subtype
|
@subtype = subtype
|
||||||
end
|
end
|
||||||
|
@ -329,6 +329,20 @@ class BSONTest < Test::Unit::TestCase
|
|||||||
bin = Binary.new
|
bin = Binary.new
|
||||||
'binstring'.each_byte { |b| bin.put(b) }
|
'binstring'.each_byte { |b| bin.put(b) }
|
||||||
|
|
||||||
|
doc = {'bin' => bin}
|
||||||
|
bson = @encoder.serialize(doc)
|
||||||
|
doc2 = @encoder.deserialize(bson)
|
||||||
|
bin2 = doc2['bin']
|
||||||
|
assert_kind_of Binary, bin2
|
||||||
|
assert_equal 'binstring', bin2.to_s
|
||||||
|
assert_equal Binary::SUBTYPE_SIMPLE, bin2.subtype
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_binary_with_deprecated_subtype
|
||||||
|
bin = Binary.new
|
||||||
|
'binstring'.each_byte { |b| bin.put(b) }
|
||||||
|
bin.subtype = Binary::SUBTYPE_BYTES
|
||||||
|
|
||||||
doc = {'bin' => bin}
|
doc = {'bin' => bin}
|
||||||
bson = @encoder.serialize(doc)
|
bson = @encoder.serialize(doc)
|
||||||
doc2 = @encoder.deserialize(bson)
|
doc2 = @encoder.deserialize(bson)
|
||||||
@ -346,7 +360,7 @@ class BSONTest < Test::Unit::TestCase
|
|||||||
bin2 = doc2['bin']
|
bin2 = doc2['bin']
|
||||||
assert_kind_of Binary, bin2
|
assert_kind_of Binary, bin2
|
||||||
assert_equal 'somebinarystring', bin2.to_s
|
assert_equal 'somebinarystring', bin2.to_s
|
||||||
assert_equal Binary::SUBTYPE_BYTES, bin2.subtype
|
assert_equal Binary::SUBTYPE_SIMPLE, bin2.subtype
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_binary_type
|
def test_binary_type
|
||||||
@ -386,7 +400,7 @@ class BSONTest < Test::Unit::TestCase
|
|||||||
bin2 = doc2['bin']
|
bin2 = doc2['bin']
|
||||||
assert_kind_of Binary, bin2
|
assert_kind_of Binary, bin2
|
||||||
assert_equal [1, 2, 3, 4, 5], bin2.to_a
|
assert_equal [1, 2, 3, 4, 5], bin2.to_a
|
||||||
assert_equal Binary::SUBTYPE_BYTES, bin2.subtype
|
assert_equal Binary::SUBTYPE_SIMPLE, bin2.subtype
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_put_id_first
|
def test_put_id_first
|
||||||
|
Loading…
Reference in New Issue
Block a user