From 3a0cdf64afcd602db5111eebf1b2ba287cfb6b5c Mon Sep 17 00:00:00 2001 From: Kyle Banker Date: Mon, 4 Oct 2010 14:37:19 -0400 Subject: [PATCH] remove deprecated support for implicit --- lib/mongo/cursor.rb | 22 +--------------------- test/db_api_test.rb | 10 ---------- 2 files changed, 1 insertion(+), 31 deletions(-) diff --git a/lib/mongo/cursor.rb b/lib/mongo/cursor.rb index e7cc156..efdba91 100644 --- a/lib/mongo/cursor.rb +++ b/lib/mongo/cursor.rb @@ -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 diff --git a/test/db_api_test.rb b/test/db_api_test.rb index f5e3203..631bf7f 100644 --- a/test/db_api_test.rb +++ b/test/db_api_test.rb @@ -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)