remove deprecated support for implicit
This commit is contained in:
parent
b8d6f57602
commit
3a0cdf64af
|
@ -39,7 +39,7 @@ module Mongo
|
||||||
@connection = @db.connection
|
@connection = @db.connection
|
||||||
@logger = @connection.logger
|
@logger = @connection.logger
|
||||||
|
|
||||||
@selector = convert_selector_for_query(options[:selector])
|
@selector = options[:selector] || {}
|
||||||
@fields = convert_fields_for_query(options[:fields])
|
@fields = convert_fields_for_query(options[:fields])
|
||||||
@skip = options[:skip] || 0
|
@skip = options[:skip] || 0
|
||||||
@limit = options[:limit] || 0
|
@limit = options[:limit] || 0
|
||||||
|
@ -327,26 +327,6 @@ module Mongo
|
||||||
end
|
end
|
||||||
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.
|
# Return the number of documents remaining for this cursor.
|
||||||
def num_remaining
|
def num_remaining
|
||||||
refresh if @cache.length == 0
|
refresh if @cache.length == 0
|
||||||
|
|
|
@ -454,16 +454,6 @@ class DBAPITest < Test::Unit::TestCase
|
||||||
assert_equal 2, @@coll.find('$where' => BSON::Code.new('this.a > i', {'i' => 1})).count()
|
assert_equal 2, @@coll.find('$where' => BSON::Code.new('this.a > i', {'i' => 1})).count()
|
||||||
end
|
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
|
def test_eval
|
||||||
assert_equal 3, @@db.eval('function (x) {return x;}', 3)
|
assert_equal 3, @@db.eval('function (x) {return x;}', 3)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue