Merge branch 'master' of git://github.com/jimm/mongo-ruby-driver
This commit is contained in:
commit
e853e037c5
3
README
3
README
|
@ -52,6 +52,9 @@ type
|
||||||
|
|
||||||
= To Do
|
= To Do
|
||||||
|
|
||||||
|
* Tests that prove that this driver's ObjectID and Geir's Java version do the
|
||||||
|
same thing.
|
||||||
|
|
||||||
* Capped collection support.
|
* Capped collection support.
|
||||||
|
|
||||||
* Implement order_by (right now, sort order is ignored)
|
* Implement order_by (right now, sort order is ignored)
|
||||||
|
|
|
@ -184,10 +184,7 @@ class BSON
|
||||||
end
|
end
|
||||||
|
|
||||||
def deserialize_oid_data(buf)
|
def deserialize_oid_data(buf)
|
||||||
high_bytes = buf.get_long
|
XGen::Mongo::Driver::ObjectID.new(buf.get(12))
|
||||||
low_bytes = buf.get_int
|
|
||||||
hexval = (high_bytes << 32) + low_bytes
|
|
||||||
XGen::Mongo::Driver::ObjectID.new('%012x' % hexval)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def serialize_eoo_element(buf)
|
def serialize_eoo_element(buf)
|
||||||
|
@ -254,11 +251,7 @@ class BSON
|
||||||
buf.put(OID)
|
buf.put(OID)
|
||||||
self.class.serialize_cstr(buf, key)
|
self.class.serialize_cstr(buf, key)
|
||||||
|
|
||||||
hexval = val.to_s.hex
|
buf.put_array(val.to_a)
|
||||||
high_bytes = hexval >> 32
|
|
||||||
low_bytes = hexval && 0xffffffff
|
|
||||||
buf.put_long(high_bytes)
|
|
||||||
buf.put_int(low_bytes)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def serialize_string_element(buf, key, val, type)
|
def serialize_string_element(buf, key, val, type)
|
||||||
|
|
|
@ -51,4 +51,18 @@ class ObjectIDTest < Test::Unit::TestCase
|
||||||
assert_equal 24, $1.length
|
assert_equal 24, $1.length
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_save_and_restore
|
||||||
|
host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
|
||||||
|
port = ENV['MONGO_RUBY_DRIVER_PORT'] || XGen::Mongo::Driver::Mongo::DEFAULT_PORT
|
||||||
|
db = XGen::Mongo::Driver::Mongo.new(host, port).db('ruby-mongo-test')
|
||||||
|
coll = db.collection('test')
|
||||||
|
|
||||||
|
coll.clear
|
||||||
|
coll << {'a' => 1, '_id' => @o}
|
||||||
|
|
||||||
|
row = coll.find().collect.first
|
||||||
|
assert_equal 1, row['a']
|
||||||
|
assert_equal @o, row['_id']
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
Loading…
Reference in New Issue