minor: updates for removal deprecated DB and Connection methods and ObjectID
This commit is contained in:
parent
bd4b6060f7
commit
b3ed1486e5
|
@ -75,7 +75,6 @@ static ID lt_operator;
|
||||||
static ID gt_operator;
|
static ID gt_operator;
|
||||||
|
|
||||||
static VALUE Binary;
|
static VALUE Binary;
|
||||||
static VALUE ObjectID;
|
|
||||||
static VALUE ObjectId;
|
static VALUE ObjectId;
|
||||||
static VALUE DBRef;
|
static VALUE DBRef;
|
||||||
static VALUE Code;
|
static VALUE Code;
|
||||||
|
@ -365,7 +364,7 @@ static int write_element(VALUE key, VALUE value, VALUE extra, int allow_id) {
|
||||||
SAFE_WRITE(buffer, RSTRING_PTR(string_data), length);
|
SAFE_WRITE(buffer, RSTRING_PTR(string_data), length);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ((strcmp(cls, "BSON::ObjectId") == 0) || (strcmp(cls, "BSON::ObjectID") == 0)) {
|
if (strcmp(cls, "BSON::ObjectId") == 0) {
|
||||||
VALUE as_array = rb_funcall(value, rb_intern("to_a"), 0);
|
VALUE as_array = rb_funcall(value, rb_intern("to_a"), 0);
|
||||||
int i;
|
int i;
|
||||||
write_name_and_type(buffer, key, 0x07);
|
write_name_and_type(buffer, key, 0x07);
|
||||||
|
@ -917,8 +916,6 @@ void Init_cbson() {
|
||||||
bson = rb_const_get(rb_cObject, rb_intern("BSON"));
|
bson = rb_const_get(rb_cObject, rb_intern("BSON"));
|
||||||
rb_require("bson/types/binary");
|
rb_require("bson/types/binary");
|
||||||
Binary = rb_const_get(bson, rb_intern("Binary"));
|
Binary = rb_const_get(bson, rb_intern("Binary"));
|
||||||
rb_require("bson/types/objectid");
|
|
||||||
ObjectID = rb_const_get(bson, rb_intern("ObjectID"));
|
|
||||||
rb_require("bson/types/object_id");
|
rb_require("bson/types/object_id");
|
||||||
ObjectId = rb_const_get(bson, rb_intern("ObjectId"));
|
ObjectId = rb_const_get(bson, rb_intern("ObjectId"));
|
||||||
rb_require("bson/types/dbref");
|
rb_require("bson/types/dbref");
|
||||||
|
@ -947,7 +944,6 @@ void Init_cbson() {
|
||||||
Digest = rb_const_get(rb_cObject, rb_intern("Digest"));
|
Digest = rb_const_get(rb_cObject, rb_intern("Digest"));
|
||||||
DigestMD5 = rb_const_get(Digest, rb_intern("MD5"));
|
DigestMD5 = rb_const_get(Digest, rb_intern("MD5"));
|
||||||
|
|
||||||
rb_define_method(ObjectID, "generate", objectid_generate, 0);
|
|
||||||
rb_define_method(ObjectId, "generate", objectid_generate, 0);
|
rb_define_method(ObjectId, "generate", objectid_generate, 0);
|
||||||
|
|
||||||
if (gethostname(hostname, MAX_HOSTNAME_LENGTH) != 0) {
|
if (gethostname(hostname, MAX_HOSTNAME_LENGTH) != 0) {
|
||||||
|
|
|
@ -55,11 +55,12 @@ else
|
||||||
module BSON
|
module BSON
|
||||||
BSON_CODER = BSON_C
|
BSON_CODER = BSON_C
|
||||||
end
|
end
|
||||||
rescue LoadError
|
rescue LoadError => e
|
||||||
require 'bson/bson_ruby'
|
require 'bson/bson_ruby'
|
||||||
module BSON
|
module BSON
|
||||||
BSON_CODER = BSON_RUBY
|
BSON_CODER = BSON_RUBY
|
||||||
end
|
end
|
||||||
|
p e
|
||||||
warn "\n**Notice: C extension not loaded. This is required for optimum MongoDB Ruby driver performance."
|
warn "\n**Notice: C extension not loaded. This is required for optimum MongoDB Ruby driver performance."
|
||||||
warn " You can install the extension as follows:\n gem install bson_ext\n"
|
warn " You can install the extension as follows:\n gem install bson_ext\n"
|
||||||
warn " If you continue to receive this message after installing, make sure that the"
|
warn " If you continue to receive this message after installing, make sure that the"
|
||||||
|
@ -70,7 +71,6 @@ end
|
||||||
require 'bson/types/binary'
|
require 'bson/types/binary'
|
||||||
require 'bson/types/code'
|
require 'bson/types/code'
|
||||||
require 'bson/types/dbref'
|
require 'bson/types/dbref'
|
||||||
require 'bson/types/objectid'
|
|
||||||
require 'bson/types/object_id'
|
require 'bson/types/object_id'
|
||||||
require 'bson/types/min_max_keys'
|
require 'bson/types/min_max_keys'
|
||||||
|
|
||||||
|
|
|
@ -130,7 +130,7 @@ class TestConnection < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_nodes
|
def test_nodes
|
||||||
db = Connection.paired([['foo', 27017], ['bar', 27018]], :connect => false)
|
db = Connection.multi([['foo', 27017], ['bar', 27018]], :connect => false)
|
||||||
nodes = db.nodes
|
nodes = db.nodes
|
||||||
assert_equal 2, nodes.length
|
assert_equal 2, nodes.length
|
||||||
assert_equal ['foo', 27017], nodes[0]
|
assert_equal ['foo', 27017], nodes[0]
|
||||||
|
@ -139,7 +139,7 @@ class TestConnection < Test::Unit::TestCase
|
||||||
|
|
||||||
def test_slave_ok_with_multiple_nodes
|
def test_slave_ok_with_multiple_nodes
|
||||||
assert_raise MongoArgumentError do
|
assert_raise MongoArgumentError do
|
||||||
Connection.paired([['foo', 27017], ['bar', 27018]], :connect => false, :slave_ok => true)
|
Connection.multi([['foo', 27017], ['bar', 27018]], :connect => false, :slave_ok => true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -75,20 +75,6 @@ class DBTest < Test::Unit::TestCase
|
||||||
assert_kind_of Collection, colls[0]
|
assert_kind_of Collection, colls[0]
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_pair
|
|
||||||
@@conn.close
|
|
||||||
@@users = nil
|
|
||||||
@@conn = Connection.paired([["this-should-fail", 27017], [@@host, @@port]])
|
|
||||||
@@db = @@conn[MONGO_TEST_DB]
|
|
||||||
assert @@conn.connected?
|
|
||||||
ensure
|
|
||||||
unless @@conn.connected?
|
|
||||||
@@conn = Connection.new(@@host, @@port)
|
|
||||||
@@db = @@conn.db(MONGO_TEST_DB)
|
|
||||||
end
|
|
||||||
@@users = @@db.collection('system.users')
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_pk_factory
|
def test_pk_factory
|
||||||
db = Connection.new(@@host, @@port).db(MONGO_TEST_DB, :pk => TestPKFactory.new)
|
db = Connection.new(@@host, @@port).db(MONGO_TEST_DB, :pk => TestPKFactory.new)
|
||||||
coll = db.collection('test')
|
coll = db.collection('test')
|
||||||
|
|
Loading…
Reference in New Issue