File tree Expand file tree Collapse file tree 2 files changed +1
-31
lines changed Expand file tree Collapse file tree 2 files changed +1
-31
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ def initialize(collection, options={})
39
39
@connection = @db . connection
40
40
@logger = @connection . logger
41
41
42
- @selector = convert_selector_for_query ( options [ :selector ] )
42
+ @selector = options [ :selector ] || { }
43
43
@fields = convert_fields_for_query ( options [ :fields ] )
44
44
@skip = options [ :skip ] || 0
45
45
@limit = options [ :limit ] || 0
@@ -327,26 +327,6 @@ def convert_fields_for_query(fields)
327
327
end
328
328
end
329
329
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
-
350
330
# Return the number of documents remaining for this cursor.
351
331
def num_remaining
352
332
refresh if @cache . length == 0
Original file line number Diff line number Diff line change @@ -454,16 +454,6 @@ def test_where
454
454
assert_equal 2 , @@coll . find ( '$where' => BSON ::Code . new ( 'this.a > i' , { 'i' => 1 } ) ) . count ( )
455
455
end
456
456
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
-
467
457
def test_eval
468
458
assert_equal 3 , @@db . eval ( 'function (x) {return x;}' , 3 )
469
459
You can’t perform that action at this time.
0 commit comments