complete deprecation of a bunch of stuff
This commit is contained in:
parent
f41b48a51b
commit
2b701119e1
|
@ -371,10 +371,6 @@ static int write_element_allow_id(VALUE key, VALUE value, VALUE extra, int allow
|
|||
memcpy(buffer->buffer + length_location, &obj_length, 4);
|
||||
break;
|
||||
}
|
||||
if (strcmp(cls, "Mongo::Undefined") == 0) {
|
||||
write_name_and_type(buffer, key, 0x0A); // just use nil type
|
||||
break;
|
||||
}
|
||||
}
|
||||
case T_DATA:
|
||||
{
|
||||
|
|
35
lib/mongo.rb
35
lib/mongo.rb
|
@ -2,7 +2,6 @@ require 'mongo/types/binary'
|
|||
require 'mongo/types/dbref'
|
||||
require 'mongo/types/objectid'
|
||||
require 'mongo/types/regexp_of_holding'
|
||||
require 'mongo/types/undefined'
|
||||
|
||||
require 'mongo/errors'
|
||||
require 'mongo/connection'
|
||||
|
@ -18,37 +17,3 @@ module Mongo
|
|||
|
||||
VERSION = "0.14.1"
|
||||
end
|
||||
|
||||
# DEPRECATED - the XGen namespace is deprecated and will be removed - use Mongo or GridFS instead
|
||||
MongoCopy = Mongo
|
||||
module XGen
|
||||
require 'mongo/gridfs'
|
||||
GridFSCopy = GridFS
|
||||
|
||||
def self.included(other_module)
|
||||
warn "the XGen module is deprecated and will be removed - use Mongo or GridFS instead (included from: #{other_module})"
|
||||
end
|
||||
|
||||
module Mongo
|
||||
include MongoCopy
|
||||
|
||||
def self.included(other_module)
|
||||
warn "the XGen::Mongo module is deprecated and will be removed - use Mongo instead (included from: #{other_module})"
|
||||
end
|
||||
|
||||
module Driver
|
||||
include MongoCopy
|
||||
|
||||
def self.included(other_module)
|
||||
warn "the XGen::Mongo::Driver module is deprecated and will be removed - use Mongo instead (included from: #{other_module})"
|
||||
end
|
||||
end
|
||||
module GridFS
|
||||
include GridFSCopy
|
||||
|
||||
def self.included(other_module)
|
||||
warn "the XGen::Mongo::GridFS module is deprecated and will be removed - use GridFS instead (included from: #{other_module})"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -148,14 +148,6 @@ module Mongo
|
|||
find(spec, options.merge(:limit => -1)).next_object
|
||||
end
|
||||
|
||||
# DEPRECATED - use find_one instead
|
||||
#
|
||||
# Find the first record that matches +selector+. See #find.
|
||||
def find_first(selector={}, options={})
|
||||
warn "Collection#find_first is deprecated and will be removed. Please use Collection#find_one instead."
|
||||
find_one(selector, options)
|
||||
end
|
||||
|
||||
# Save a document in this collection.
|
||||
#
|
||||
# If +to_save+ already has an '_id' then an update (upsert) operation
|
||||
|
@ -214,32 +206,6 @@ module Mongo
|
|||
remove({})
|
||||
end
|
||||
|
||||
# DEPRECATED - use update(... :upsert => true) instead
|
||||
#
|
||||
# Update records that match +selector+ by applying +obj+ as an update.
|
||||
# If no match, inserts (???).
|
||||
def repsert(selector, obj)
|
||||
warn "Collection#repsert is deprecated and will be removed. Please use Collection#update instead."
|
||||
update(selector, obj, :upsert => true)
|
||||
end
|
||||
|
||||
# DEPRECATED - use update(... :upsert => false) instead
|
||||
#
|
||||
# Update records that match +selector+ by applying +obj+ as an update.
|
||||
def replace(selector, obj)
|
||||
warn "Collection#replace is deprecated and will be removed. Please use Collection#update instead."
|
||||
update(selector, obj)
|
||||
end
|
||||
|
||||
# DEPRECATED - use update(... :upsert => false) instead
|
||||
#
|
||||
# Update records that match +selector+ by applying +obj+ as an update.
|
||||
# Both +selector+ and +modifier_obj+ are required.
|
||||
def modify(selector, modifier_obj)
|
||||
warn "Collection#modify is deprecated and will be removed. Please use Collection#update instead."
|
||||
update(selector, modifier_obj)
|
||||
end
|
||||
|
||||
# Update a single document in this collection.
|
||||
#
|
||||
# :spec :: a hash specifying elements which must be present for
|
||||
|
@ -420,14 +386,8 @@ EOS
|
|||
end
|
||||
|
||||
# Get the number of documents in this collection.
|
||||
#
|
||||
# Specifying a +selector+ is DEPRECATED and will be removed. Please use
|
||||
# find(selector).count() instead.
|
||||
def count(selector=nil)
|
||||
if selector
|
||||
warn "specifying a selector for Collection#count is deprecated and will be removed. Please use Collection.find(selector).count instead."
|
||||
end
|
||||
find(selector || {}).count()
|
||||
def count()
|
||||
find().count()
|
||||
end
|
||||
|
||||
protected
|
||||
|
|
|
@ -148,12 +148,4 @@ module Mongo
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Mongo < Connection
|
||||
def initialize(pair_or_host=nil, port=nil, options={})
|
||||
super(pair_or_host, port, options)
|
||||
|
||||
warn "Mongo::Mongo is deprecated and will be removed - please use Mongo::Connection"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -388,12 +388,6 @@ module Mongo
|
|||
}
|
||||
end
|
||||
|
||||
# DEPRECATED - use Collection#update instead
|
||||
def modify_in_db(collection_name, selector, obj)
|
||||
warn "DB#modify_in_db is deprecated and will be removed. Please use Collection#update instead."
|
||||
replace_in_db(collection_name, selector, obj)
|
||||
end
|
||||
|
||||
# Update records in +collection_name+ that match +selector+ by
|
||||
# applying +obj+ as an update. If no match, inserts (???). Normally
|
||||
# called by Collection#repsert.
|
||||
|
@ -405,12 +399,6 @@ module Mongo
|
|||
}
|
||||
end
|
||||
|
||||
# DEPRECATED - use Collection.find(selector).count() instead
|
||||
def count(collection_name, selector={})
|
||||
warn "DB#count is deprecated and will be removed. Please use Collection.find(selector).count instead."
|
||||
collection(collection_name).find(selector).count()
|
||||
end
|
||||
|
||||
# Dereference a DBRef, getting the document it points to.
|
||||
def dereference(dbref)
|
||||
collection(dbref.namespace).find_one("_id" => dbref.object_id)
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
# --
|
||||
# Copyright (C) 2008-2009 10gen Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# ++
|
||||
|
||||
module Mongo
|
||||
|
||||
# DEPRECATED - the ruby driver converts the BSON undefined type to nil,
|
||||
# and saves this type as nil
|
||||
class Undefined < Object
|
||||
|
||||
def initialize
|
||||
super
|
||||
warn "the Undefined type is deprecated and will be removed - BSON undefineds get implicitly converted to nil now"
|
||||
end
|
||||
end
|
||||
end
|
|
@ -21,7 +21,6 @@ require 'mongo/types/binary'
|
|||
require 'mongo/types/dbref'
|
||||
require 'mongo/types/objectid'
|
||||
require 'mongo/types/regexp_of_holding'
|
||||
require 'mongo/types/undefined'
|
||||
|
||||
# A BSON seralizer/deserializer.
|
||||
class BSON
|
||||
|
@ -539,8 +538,6 @@ class BSON
|
|||
OBJECT
|
||||
when Symbol
|
||||
SYMBOL
|
||||
when Undefined
|
||||
NULL
|
||||
else
|
||||
raise "Unknown type of object: #{o.class.name}"
|
||||
end
|
||||
|
|
|
@ -194,13 +194,6 @@ class BSONTest < Test::Unit::TestCase
|
|||
assert_equal Binary::SUBTYPE_BYTES, bin2.subtype
|
||||
end
|
||||
|
||||
def test_undefined
|
||||
doc = {'undef' => Undefined.new}
|
||||
@b.serialize(doc)
|
||||
doc2 = @b.deserialize
|
||||
assert_equal nil, doc2['undef']
|
||||
end
|
||||
|
||||
def test_put_id_first
|
||||
val = OrderedHash.new
|
||||
val['not_id'] = 1
|
||||
|
|
|
@ -110,9 +110,6 @@ class TestCollection < Test::Unit::TestCase
|
|||
@@test.save("x" => 1)
|
||||
@@test.save("x" => 2)
|
||||
assert_equal 2, @@test.count
|
||||
|
||||
# TODO remove this test - it's deprecated
|
||||
assert_equal 1, @@test.count("x" => 1)
|
||||
end
|
||||
|
||||
def test_find_one
|
||||
|
|
|
@ -99,28 +99,3 @@ class TestConnection < Test::Unit::TestCase
|
|||
assert_equal ['foo', 123], pair[1]
|
||||
end
|
||||
end
|
||||
|
||||
# Test for deprecated Mongo class
|
||||
class TestMongo < Test::Unit::TestCase
|
||||
|
||||
include Mongo
|
||||
|
||||
def setup
|
||||
@host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
|
||||
@port = ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::DEFAULT_PORT
|
||||
@mongo = Mongo.new(@host, @port)
|
||||
end
|
||||
|
||||
def test_database_info
|
||||
@mongo.drop_database('ruby-mongo-info-test')
|
||||
@mongo.db('ruby-mongo-info-test').collection('info-test').insert('a' => 1)
|
||||
|
||||
info = @mongo.database_info
|
||||
assert_not_nil info
|
||||
assert_kind_of Hash, info
|
||||
assert_not_nil info['ruby-mongo-info-test']
|
||||
assert info['ruby-mongo-info-test'] > 0
|
||||
|
||||
@mongo.drop_database('ruby-mongo-info-test')
|
||||
end
|
||||
end
|
||||
|
|
|
@ -239,12 +239,6 @@ class DBAPITest < Test::Unit::TestCase
|
|||
assert_equal 4, docs.size
|
||||
end
|
||||
|
||||
def test_find_first
|
||||
x = @@coll.find_first('a' => 1)
|
||||
assert_not_nil x
|
||||
assert_equal 1, x['a']
|
||||
end
|
||||
|
||||
def test_find_one_no_records
|
||||
@@coll.clear
|
||||
x = @@coll.find_one('a' => 1)
|
||||
|
@ -470,32 +464,6 @@ class DBAPITest < Test::Unit::TestCase
|
|||
@@db.drop_collection('foobar')
|
||||
end
|
||||
|
||||
def test_replace
|
||||
assert_equal @@coll.count, 1
|
||||
assert_equal @@coll.find_one["a"], 1
|
||||
|
||||
@@coll.replace({"a" => 1}, {"a" => 2})
|
||||
assert_equal @@coll.count, 1
|
||||
assert_equal @@coll.find_one["a"], 2
|
||||
|
||||
@@coll.replace({"b" => 1}, {"a" => 3})
|
||||
assert_equal @@coll.count, 1
|
||||
assert_equal @@coll.find_one["a"], 2
|
||||
end
|
||||
|
||||
def test_repsert
|
||||
assert_equal @@coll.count, 1
|
||||
assert_equal @@coll.find_one["a"], 1
|
||||
|
||||
@@coll.repsert({"a" => 1}, {"a" => 2})
|
||||
assert_equal @@coll.count, 1
|
||||
assert_equal @@coll.find_one["a"], 2
|
||||
|
||||
@@coll.repsert({"b" => 1}, {"a" => 3})
|
||||
assert_equal @@coll.count, 2
|
||||
assert @@coll.find_one({"a" => 3})
|
||||
end
|
||||
|
||||
def test_to_a
|
||||
cursor = @@coll.find()
|
||||
rows = cursor.to_a
|
||||
|
@ -730,8 +698,6 @@ class DBAPITest < Test::Unit::TestCase
|
|||
assert_raise InvalidName do
|
||||
@@coll.insert({"hello" => {"hel.lo" => "world"}})
|
||||
end
|
||||
|
||||
@@coll.modify({"hello" => "world"}, {"$inc" => "hello"})
|
||||
end
|
||||
|
||||
def test_collection_names
|
||||
|
|
|
@ -1,73 +0,0 @@
|
|||
# Copyright (C) 2009 10gen Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
$LOAD_PATH[0,0] = File.join(File.dirname(__FILE__), '..', 'lib')
|
||||
require 'mongo'
|
||||
require 'test/unit'
|
||||
|
||||
# TODO these tests should be removed - just testing for the deprecated
|
||||
# XGen::Mongo::Driver include path
|
||||
class TestXGen < Test::Unit::TestCase
|
||||
@@db = XGen::Mongo::Driver::Connection.new(ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost',
|
||||
ENV['MONGO_RUBY_DRIVER_PORT'] || XGen::Mongo::Driver::Connection::DEFAULT_PORT).db('ruby-mongo-test')
|
||||
@@test = @@db.collection('test')
|
||||
|
||||
def setup
|
||||
@@test.clear
|
||||
end
|
||||
|
||||
def test_sort
|
||||
@@test.save('x' => 2)
|
||||
@@test.save('x' => 1)
|
||||
@@test.save('x' => 3)
|
||||
|
||||
assert_equal 1, @@test.find({}, :sort => {'x' => XGen::Mongo::ASCENDING}).to_a()[0]['x']
|
||||
assert_equal 3, @@test.find({}, :sort => {'x' => XGen::Mongo::DESCENDING}).to_a()[0]['x']
|
||||
end
|
||||
|
||||
def test_gridfs
|
||||
XGen::Mongo::GridFS::GridStore.open(@@db, 'foobar', 'w') { |f| f.write('hello world!') }
|
||||
assert XGen::Mongo::GridFS::GridStore.exist?(@@db, 'foobar')
|
||||
assert !XGen::Mongo::GridFS::GridStore.exist?(@@db, 'mike')
|
||||
end
|
||||
end
|
||||
|
||||
class TestXGenInclude < Test::Unit::TestCase
|
||||
include XGen::Mongo::GridFS
|
||||
include XGen::Mongo::Driver
|
||||
include XGen::Mongo
|
||||
|
||||
@@db = Connection.new(ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost',
|
||||
ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT).db('ruby-mongo-test')
|
||||
@@test = @@db.collection('test')
|
||||
|
||||
def setup
|
||||
@@test.clear
|
||||
end
|
||||
|
||||
def test_sort
|
||||
@@test.save('x' => 2)
|
||||
@@test.save('x' => 1)
|
||||
@@test.save('x' => 3)
|
||||
|
||||
assert_equal 1, @@test.find({}, :sort => {'x' => ASCENDING}).to_a()[0]['x']
|
||||
assert_equal 3, @@test.find({}, :sort => {'x' => DESCENDING}).to_a()[0]['x']
|
||||
end
|
||||
|
||||
def test_gridfs
|
||||
GridStore.open(@@db, 'foobar', 'w') { |f| f.write('hello world!') }
|
||||
assert GridStore.exist?(@@db, 'foobar')
|
||||
assert !GridStore.exist?(@@db, 'mike')
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue