Skip to content

Commit 3a0cdf6

Browse files
committed
remove deprecated support for implicit
1 parent b8d6f57 commit 3a0cdf6

File tree

2 files changed

+1
-31
lines changed

2 files changed

+1
-31
lines changed

lib/mongo/cursor.rb

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def initialize(collection, options={})
3939
@connection = @db.connection
4040
@logger = @connection.logger
4141

42-
@selector = convert_selector_for_query(options[:selector])
42+
@selector = options[:selector] || {}
4343
@fields = convert_fields_for_query(options[:fields])
4444
@skip = options[:skip] || 0
4545
@limit = options[:limit] || 0
@@ -327,26 +327,6 @@ def convert_fields_for_query(fields)
327327
end
328328
end
329329

330-
# Set the query selector hash. If the selector is a Code or String object,
331-
# the selector will be used in a $where clause.
332-
# See http://www.mongodb.org/display/DOCS/Server-side+Code+Execution
333-
def convert_selector_for_query(selector)
334-
case selector
335-
when Hash
336-
selector
337-
when nil
338-
{}
339-
when BSON::Code
340-
warn "Collection#find will no longer take a JavaScript string in future versions. " +
341-
"Please specify your $where query explicitly."
342-
{"$where" => selector}
343-
when String
344-
warn "Collection#find will no longer take a JavaScript string in future versions. " +
345-
"Please specify your $where query explicitly."
346-
{"$where" => BSON::Code.new(selector)}
347-
end
348-
end
349-
350330
# Return the number of documents remaining for this cursor.
351331
def num_remaining
352332
refresh if @cache.length == 0

test/db_api_test.rb

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -454,16 +454,6 @@ def test_where
454454
assert_equal 2, @@coll.find('$where' => BSON::Code.new('this.a > i', {'i' => 1})).count()
455455
end
456456

457-
def test_implicit_where
458-
@@coll.remove
459-
@@coll.insert('a' => 2)
460-
@@coll.insert('a' => 3)
461-
462-
assert_equal 2, @@coll.count
463-
assert_equal 1, @@coll.find('this.a > 2').count()
464-
assert_equal 2, @@coll.find(BSON::Code.new('this.a > z', {'z' => 1})).to_a.length
465-
end
466-
467457
def test_eval
468458
assert_equal 3, @@db.eval('function (x) {return x;}', 3)
469459

0 commit comments

Comments
 (0)