remove deprecated support for implicit

This commit is contained in:
Kyle Banker 2010-10-04 14:37:19 -04:00
parent b8d6f57602
commit 3a0cdf64af
2 changed files with 1 additions and 31 deletions

View File

@ -39,7 +39,7 @@ module Mongo
@connection = @db.connection
@logger = @connection.logger
@selector = convert_selector_for_query(options[:selector])
@selector = options[:selector] || {}
@fields = convert_fields_for_query(options[:fields])
@skip = options[:skip] || 0
@limit = options[:limit] || 0
@ -327,26 +327,6 @@ module Mongo
end
end
# Set the query selector hash. If the selector is a Code or String object,
# the selector will be used in a $where clause.
# See http://www.mongodb.org/display/DOCS/Server-side+Code+Execution
def convert_selector_for_query(selector)
case selector
when Hash
selector
when nil
{}
when BSON::Code
warn "Collection#find will no longer take a JavaScript string in future versions. " +
"Please specify your $where query explicitly."
{"$where" => selector}
when String
warn "Collection#find will no longer take a JavaScript string in future versions. " +
"Please specify your $where query explicitly."
{"$where" => BSON::Code.new(selector)}
end
end
# Return the number of documents remaining for this cursor.
def num_remaining
refresh if @cache.length == 0

View File

@ -454,16 +454,6 @@ class DBAPITest < Test::Unit::TestCase
assert_equal 2, @@coll.find('$where' => BSON::Code.new('this.a > i', {'i' => 1})).count()
end
def test_implicit_where
@@coll.remove
@@coll.insert('a' => 2)
@@coll.insert('a' => 3)
assert_equal 2, @@coll.count
assert_equal 1, @@coll.find('this.a > 2').count()
assert_equal 2, @@coll.find(BSON::Code.new('this.a > z', {'z' => 1})).to_a.length
end
def test_eval
assert_equal 3, @@db.eval('function (x) {return x;}', 3)