Fixed symbol ser/deser
This commit is contained in:
parent
b25c91516f
commit
74773efe0c
|
@ -80,7 +80,7 @@ class BSON
|
||||||
obj.each {|k, v|
|
obj.each {|k, v|
|
||||||
type = bson_type(v, k)
|
type = bson_type(v, k)
|
||||||
case type
|
case type
|
||||||
when STRING, CODE
|
when STRING, CODE, SYMBOL
|
||||||
serialize_string_element(@buf, k, v, type)
|
serialize_string_element(@buf, k, v, type)
|
||||||
when NUMBER, NUMBER_INT
|
when NUMBER, NUMBER_INT
|
||||||
serialize_number_element(@buf, k, v, type)
|
serialize_number_element(@buf, k, v, type)
|
||||||
|
@ -100,8 +100,6 @@ class BSON
|
||||||
serialize_null_element(@buf, k)
|
serialize_null_element(@buf, k)
|
||||||
when REF
|
when REF
|
||||||
serialize_dbref_element(@buf, k, v)
|
serialize_dbref_element(@buf, k, v)
|
||||||
when SYMBOL
|
|
||||||
serialize_symbol_element(@buf, k, v)
|
|
||||||
when BINARY
|
when BINARY
|
||||||
serialize_binary_element(@buf, k, v)
|
serialize_binary_element(@buf, k, v)
|
||||||
when UNDEFINED
|
when UNDEFINED
|
||||||
|
@ -131,6 +129,9 @@ class BSON
|
||||||
when STRING, CODE
|
when STRING, CODE
|
||||||
key = deserialize_cstr(@buf)
|
key = deserialize_cstr(@buf)
|
||||||
doc[key] = deserialize_string_data(@buf)
|
doc[key] = deserialize_string_data(@buf)
|
||||||
|
when SYMBOL
|
||||||
|
key = deserialize_cstr(@buf)
|
||||||
|
doc[key] = deserialize_string_data(@buf).intern
|
||||||
when NUMBER
|
when NUMBER
|
||||||
key = deserialize_cstr(@buf)
|
key = deserialize_cstr(@buf)
|
||||||
doc[key] = deserialize_number_data(@buf)
|
doc[key] = deserialize_number_data(@buf)
|
||||||
|
@ -164,9 +165,6 @@ class BSON
|
||||||
when REF
|
when REF
|
||||||
key = deserialize_cstr(@buf)
|
key = deserialize_cstr(@buf)
|
||||||
doc[key] = deserialize_dbref_data(@buf, key, parent)
|
doc[key] = deserialize_dbref_data(@buf, key, parent)
|
||||||
when SYMBOL
|
|
||||||
key = deserialize_cstr(@buf)
|
|
||||||
doc[key] = deserialize_symbol_data(@buf)
|
|
||||||
when BINARY
|
when BINARY
|
||||||
key = deserialize_cstr(@buf)
|
key = deserialize_cstr(@buf)
|
||||||
doc[key] = deserialize_binary_data(@buf)
|
doc[key] = deserialize_binary_data(@buf)
|
||||||
|
@ -259,10 +257,6 @@ class BSON
|
||||||
XGen::Mongo::Driver::DBRef.new(parent, key, @db, ns, oid)
|
XGen::Mongo::Driver::DBRef.new(parent, key, @db, ns, oid)
|
||||||
end
|
end
|
||||||
|
|
||||||
def deserialize_symbol_data(buf)
|
|
||||||
deserialize_cstr(buf).intern
|
|
||||||
end
|
|
||||||
|
|
||||||
def deserialize_binary_data(buf)
|
def deserialize_binary_data(buf)
|
||||||
len = buf.get_int
|
len = buf.get_int
|
||||||
bytes = buf.get(len)
|
bytes = buf.get(len)
|
||||||
|
@ -287,12 +281,6 @@ class BSON
|
||||||
buf.put_array(val.object_id.to_a)
|
buf.put_array(val.object_id.to_a)
|
||||||
end
|
end
|
||||||
|
|
||||||
def serialize_symbol_element(buf, key, val)
|
|
||||||
buf.put(SYMBOL)
|
|
||||||
self.class.serialize_cstr(buf, key)
|
|
||||||
self.class.serialize_cstr(buf, val)
|
|
||||||
end
|
|
||||||
|
|
||||||
def serialize_binary_element(buf, key, val)
|
def serialize_binary_element(buf, key, val)
|
||||||
buf.put(BINARY)
|
buf.put(BINARY)
|
||||||
self.class.serialize_cstr(buf, key)
|
self.class.serialize_cstr(buf, key)
|
||||||
|
|
Loading…
Reference in New Issue