mongo 1.0.8 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/insert.rb +35 -0
- data/bin/mongo_console +21 -0
- data/bin/oid.rb +13 -0
- data/lib/mongo.rb +1 -1
- data/lib/mongo/collection.rb +19 -19
- data/lib/mongo/connection.rb +91 -51
- data/lib/mongo/cursor.rb +59 -23
- data/lib/mongo/util/core_ext.rb +15 -4
- data/mongo.gemspec +3 -0
- data/test/auxillary/1.4_features.rb +1 -1
- data/test/auxillary/authentication_test.rb +1 -1
- data/test/auxillary/autoreconnect_test.rb +1 -1
- data/test/auxillary/slave_connection_test.rb +1 -1
- data/test/collection_test.rb +2 -1
- data/test/connection_test.rb +1 -1
- data/test/conversions_test.rb +1 -1
- data/test/cursor_fail_test.rb +1 -1
- data/test/cursor_message_test.rb +22 -10
- data/test/cursor_test.rb +5 -4
- data/test/db_api_test.rb +1 -1
- data/test/db_connection_test.rb +2 -2
- data/test/db_test.rb +3 -4
- data/test/grid_file_system_test.rb +1 -1
- data/test/grid_io_test.rb +1 -1
- data/test/grid_test.rb +2 -2
- data/test/replica_pairs/count_test.rb +1 -1
- data/test/replica_pairs/insert_test.rb +1 -1
- data/test/replica_pairs/pooled_insert_test.rb +1 -1
- data/test/replica_pairs/query_test.rb +1 -1
- data/test/replica_sets/count_test.rb +1 -1
- data/test/replica_sets/insert_test.rb +1 -1
- data/test/replica_sets/node_type_test.rb +1 -1
- data/test/replica_sets/pooled_insert_test.rb +1 -1
- data/test/replica_sets/query_test.rb +1 -1
- data/test/replica_sets/replication_ack_test.rb +1 -1
- data/test/support_test.rb +1 -1
- data/test/threading_test.rb +1 -1
- data/test/unit/collection_test.rb +21 -7
- data/test/unit/connection_test.rb +1 -1
- data/test/unit/cursor_test.rb +5 -3
- data/test/unit/db_test.rb +2 -2
- metadata +9 -6
data/bin/insert.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'mongo'
|
5
|
+
require 'date'
|
6
|
+
require 'logger'
|
7
|
+
include Mongo
|
8
|
+
|
9
|
+
@logger = Logger.new(File.open("m.log", "w"))
|
10
|
+
require 'ruby-prof'
|
11
|
+
|
12
|
+
num_inserts = 100000
|
13
|
+
if( ARGV.size() > 0 ) then
|
14
|
+
num_inserts = ARGV[0].to_i()
|
15
|
+
end
|
16
|
+
db = Connection.new('localhost', 27017).db('sample-db')
|
17
|
+
coll = db.collection('test')
|
18
|
+
coll.remove()
|
19
|
+
sleep(2)
|
20
|
+
|
21
|
+
puts "Testing #{num_inserts} inserts"
|
22
|
+
start = Time.now()
|
23
|
+
|
24
|
+
#RubyProf.start
|
25
|
+
num_inserts.times do |i|
|
26
|
+
coll.insert({'a' => i+1})
|
27
|
+
end
|
28
|
+
#result = RubyProf.stop
|
29
|
+
ending = Time.now
|
30
|
+
total = ending - start
|
31
|
+
|
32
|
+
puts "Took #{total} seconds, meaning #{num_inserts / total} per second."
|
33
|
+
|
34
|
+
#printer = RubyProf::FlatPrinter.new(result)
|
35
|
+
#printer.print(STDOUT, 0)
|
data/bin/mongo_console
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
org_argv = ARGV.dup
|
3
|
+
ARGV.clear
|
4
|
+
|
5
|
+
require 'irb'
|
6
|
+
|
7
|
+
$LOAD_PATH[0,0] = File.join(File.dirname(__FILE__), '..', 'lib')
|
8
|
+
require 'mongo'
|
9
|
+
|
10
|
+
include Mongo
|
11
|
+
|
12
|
+
host = org_argv[0] || ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
|
13
|
+
port = org_argv[1] || ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT
|
14
|
+
dbnm = org_argv[2] || ENV['MONGO_RUBY_DRIVER_DB'] || 'ruby-mongo-console'
|
15
|
+
|
16
|
+
puts "Connecting to #{host}:#{port} (CONN) on with database #{dbnm} (DB)"
|
17
|
+
CONN = Connection.new(host, port)
|
18
|
+
DB = CONN.db(dbnm)
|
19
|
+
|
20
|
+
puts "Starting IRB session..."
|
21
|
+
IRB.start(__FILE__)
|
data/bin/oid.rb
ADDED
data/lib/mongo.rb
CHANGED
data/lib/mongo/collection.rb
CHANGED
@@ -58,6 +58,7 @@ module Mongo
|
|
58
58
|
|
59
59
|
@db, @name = db, name
|
60
60
|
@connection = @db.connection
|
61
|
+
@logger = @connection.logger
|
61
62
|
@pk_factory = pk_factory || BSON::ObjectId
|
62
63
|
@hint = nil
|
63
64
|
end
|
@@ -283,20 +284,19 @@ module Mongo
|
|
283
284
|
# @core remove remove-instance_method
|
284
285
|
def remove(selector={}, opts={})
|
285
286
|
# Initial byte is 0.
|
286
|
-
message = BSON::ByteBuffer.new(
|
287
|
+
message = BSON::ByteBuffer.new("\0\0\0\0")
|
287
288
|
BSON::BSON_RUBY.serialize_cstr(message, "#{@db.name}.#{@name}")
|
288
289
|
message.put_int(0)
|
289
|
-
message.
|
290
|
+
message.put_binary(BSON::BSON_CODER.serialize(selector, false, true).to_s)
|
290
291
|
|
292
|
+
@logger.debug("MONGODB #{@db.name}['#{@name}'].remove(#{selector.inspect})") if @logger
|
291
293
|
if opts[:safe]
|
292
|
-
@connection.send_message_with_safe_check(Mongo::Constants::OP_DELETE, message, @db.name,
|
293
|
-
"#{@db.name}['#{@name}'].remove(#{selector.inspect})", opts[:safe])
|
294
|
+
@connection.send_message_with_safe_check(Mongo::Constants::OP_DELETE, message, @db.name, nil, opts[:safe])
|
294
295
|
# the return value of send_message_with_safe_check isn't actually meaningful --
|
295
296
|
# only the fact that it didn't raise an error is -- so just return true
|
296
297
|
true
|
297
298
|
else
|
298
|
-
@connection.send_message(Mongo::Constants::OP_DELETE, message
|
299
|
-
"#{@db.name}['#{@name}'].remove(#{selector.inspect})")
|
299
|
+
@connection.send_message(Mongo::Constants::OP_DELETE, message)
|
300
300
|
end
|
301
301
|
end
|
302
302
|
|
@@ -322,20 +322,19 @@ module Mongo
|
|
322
322
|
# @core update update-instance_method
|
323
323
|
def update(selector, document, options={})
|
324
324
|
# Initial byte is 0.
|
325
|
-
message = BSON::ByteBuffer.new(
|
325
|
+
message = BSON::ByteBuffer.new("\0\0\0\0")
|
326
326
|
BSON::BSON_RUBY.serialize_cstr(message, "#{@db.name}.#{@name}")
|
327
327
|
update_options = 0
|
328
328
|
update_options += 1 if options[:upsert]
|
329
329
|
update_options += 2 if options[:multi]
|
330
330
|
message.put_int(update_options)
|
331
|
-
message.
|
332
|
-
message.
|
331
|
+
message.put_binary(BSON::BSON_CODER.serialize(selector, false, true).to_s)
|
332
|
+
message.put_binary(BSON::BSON_CODER.serialize(document, false, true).to_s)
|
333
|
+
@logger.debug("MONGODB #{@db.name}['#{@name}'].update(#{selector.inspect}, #{document.inspect})") if @logger
|
333
334
|
if options[:safe]
|
334
|
-
@connection.send_message_with_safe_check(Mongo::Constants::OP_UPDATE, message, @db.name,
|
335
|
-
"#{@db.name}['#{@name}'].update(#{selector.inspect}, #{document.inspect})", options[:safe])
|
335
|
+
@connection.send_message_with_safe_check(Mongo::Constants::OP_UPDATE, message, @db.name, nil, options[:safe])
|
336
336
|
else
|
337
|
-
@connection.send_message(Mongo::Constants::OP_UPDATE, message,
|
338
|
-
"#{@db.name}['#{@name}'].update(#{selector.inspect}, #{document.inspect})")
|
337
|
+
@connection.send_message(Mongo::Constants::OP_UPDATE, message, nil)
|
339
338
|
end
|
340
339
|
end
|
341
340
|
|
@@ -680,17 +679,18 @@ module Mongo
|
|
680
679
|
# +check_keys+ setting.
|
681
680
|
def insert_documents(documents, collection_name=@name, check_keys=true, safe=false)
|
682
681
|
# Initial byte is 0.
|
683
|
-
message = BSON::ByteBuffer.new(
|
682
|
+
message = BSON::ByteBuffer.new("\0\0\0\0")
|
684
683
|
BSON::BSON_RUBY.serialize_cstr(message, "#{@db.name}.#{collection_name}")
|
685
|
-
documents.each
|
684
|
+
documents.each do |doc|
|
685
|
+
message.put_binary(BSON::BSON_CODER.serialize(doc, check_keys, true).to_s)
|
686
|
+
end
|
686
687
|
raise InvalidOperation, "Exceded maximum insert size of 16,000,000 bytes" if message.size > 16_000_000
|
687
688
|
|
689
|
+
@logger.debug("MONGODB #{@db.name}['#{collection_name}'].insert(#{documents.inspect})") if @logger
|
688
690
|
if safe
|
689
|
-
@connection.send_message_with_safe_check(Mongo::Constants::OP_INSERT, message, @db.name,
|
690
|
-
"#{@db.name}['#{collection_name}'].insert(#{documents.inspect})", safe)
|
691
|
+
@connection.send_message_with_safe_check(Mongo::Constants::OP_INSERT, message, @db.name, nil, safe)
|
691
692
|
else
|
692
|
-
@connection.send_message(Mongo::Constants::OP_INSERT, message,
|
693
|
-
"#{@db.name}['#{collection_name}'].insert(#{documents.inspect})")
|
693
|
+
@connection.send_message(Mongo::Constants::OP_INSERT, message, nil)
|
694
694
|
end
|
695
695
|
documents.collect { |o| o[:_id] || o['_id'] }
|
696
696
|
end
|
data/lib/mongo/connection.rb
CHANGED
@@ -277,8 +277,8 @@ module Mongo
|
|
277
277
|
# @return [Hash]
|
278
278
|
def database_info
|
279
279
|
doc = self['admin'].command({:listDatabases => 1})
|
280
|
-
|
281
|
-
|
280
|
+
doc['databases'].each_with_object({}) do |db, info|
|
281
|
+
info[db['name']] = db['sizeOnDisk'].to_i
|
282
282
|
end
|
283
283
|
end
|
284
284
|
|
@@ -298,7 +298,7 @@ module Mongo
|
|
298
298
|
#
|
299
299
|
# @core databases db-instance_method
|
300
300
|
def db(db_name, options={})
|
301
|
-
DB.new(db_name, self
|
301
|
+
DB.new(db_name, self)
|
302
302
|
end
|
303
303
|
|
304
304
|
# Shortcut for returning a database. Use DB#db to accept options.
|
@@ -309,7 +309,7 @@ module Mongo
|
|
309
309
|
#
|
310
310
|
# @core databases []-instance_method
|
311
311
|
def [](db_name)
|
312
|
-
DB.new(db_name, self
|
312
|
+
DB.new(db_name, self)
|
313
313
|
end
|
314
314
|
|
315
315
|
# Drop a database.
|
@@ -388,11 +388,9 @@ module Mongo
|
|
388
388
|
#
|
389
389
|
# @param [Integer] operation a MongoDB opcode.
|
390
390
|
# @param [BSON::ByteBuffer] message a message to send to the database.
|
391
|
-
# @param [String] log_message text version of +message+ for logging.
|
392
391
|
#
|
393
392
|
# @return [Integer] number of bytes sent
|
394
393
|
def send_message(operation, message, log_message=nil)
|
395
|
-
@logger.debug(" MONGODB #{log_message || message}") if @logger
|
396
394
|
begin
|
397
395
|
packed_message = add_message_headers(operation, message).to_s
|
398
396
|
socket = checkout
|
@@ -408,7 +406,6 @@ module Mongo
|
|
408
406
|
# @param [Integer] operation a MongoDB opcode.
|
409
407
|
# @param [BSON::ByteBuffer] message a message to send to the database.
|
410
408
|
# @param [String] db_name the name of the database. used on call to get_last_error.
|
411
|
-
# @param [String] log_message text version of +message+ for logging.
|
412
409
|
# @param [Hash] last_error_params parameters to be sent to getLastError. See DB#error for
|
413
410
|
# available options.
|
414
411
|
#
|
@@ -420,7 +417,6 @@ module Mongo
|
|
420
417
|
def send_message_with_safe_check(operation, message, db_name, log_message=nil, last_error_params=false)
|
421
418
|
message_with_headers = add_message_headers(operation, message)
|
422
419
|
message_with_check = last_error_message(db_name, last_error_params)
|
423
|
-
@logger.debug(" MONGODB #{log_message || message}") if @logger
|
424
420
|
begin
|
425
421
|
sock = checkout
|
426
422
|
packed_message = message_with_headers.append!(message_with_check).to_s
|
@@ -442,7 +438,6 @@ module Mongo
|
|
442
438
|
#
|
443
439
|
# @param [Integer] operation a MongoDB opcode.
|
444
440
|
# @param [BSON::ByteBuffer] message a message to send to the database.
|
445
|
-
# @param [String] log_message text version of +message+ for logging.
|
446
441
|
# @param [Socket] socket a socket to use in lieu of checking out a new one.
|
447
442
|
#
|
448
443
|
# @return [Array]
|
@@ -450,7 +445,6 @@ module Mongo
|
|
450
445
|
# and [3] a cursor_id.
|
451
446
|
def receive_message(operation, message, log_message=nil, socket=nil)
|
452
447
|
packed_message = add_message_headers(operation, message).to_s
|
453
|
-
@logger.debug(" MONGODB #{log_message || message}") if @logger
|
454
448
|
begin
|
455
449
|
sock = socket || checkout
|
456
450
|
|
@@ -626,7 +620,7 @@ module Mongo
|
|
626
620
|
if config
|
627
621
|
update_node_list(config['hosts']) if config['hosts']
|
628
622
|
if @logger
|
629
|
-
@logger.warn(config['msg']) if config['msg']
|
623
|
+
@logger.warn("MONGODB #{config['msg']}") if config['msg']
|
630
624
|
end
|
631
625
|
end
|
632
626
|
|
@@ -737,7 +731,7 @@ module Mongo
|
|
737
731
|
|
738
732
|
# Otherwise, wait
|
739
733
|
if @logger
|
740
|
-
@logger.warn "Waiting for available connection; #{@checked_out.size} of #{@size} connections checked out."
|
734
|
+
@logger.warn "MONGODB Waiting for available connection; #{@checked_out.size} of #{@size} connections checked out."
|
741
735
|
end
|
742
736
|
@queue.wait(@connection_mutex)
|
743
737
|
end
|
@@ -745,14 +739,14 @@ module Mongo
|
|
745
739
|
end
|
746
740
|
|
747
741
|
def receive(sock)
|
748
|
-
|
742
|
+
receive_and_discard_header(sock)
|
749
743
|
number_received, cursor_id = receive_response_header(sock)
|
750
744
|
read_documents(number_received, cursor_id, sock)
|
751
745
|
end
|
752
746
|
|
753
747
|
def receive_header(sock)
|
754
748
|
header = BSON::ByteBuffer.new
|
755
|
-
header.
|
749
|
+
header.put_binary(receive_message_on_socket(16, sock))
|
756
750
|
unless header.size == STANDARD_HEADER_SIZE
|
757
751
|
raise "Short read for DB response header: " +
|
758
752
|
"expected #{STANDARD_HEADER_SIZE} bytes, saw #{header.size}"
|
@@ -763,19 +757,25 @@ module Mongo
|
|
763
757
|
response_to = header.get_int
|
764
758
|
op = header.get_int
|
765
759
|
end
|
760
|
+
|
761
|
+
def receive_and_discard_header(sock)
|
762
|
+
bytes_read = receive_and_discard_message_on_socket(16, sock)
|
763
|
+
unless bytes_read == STANDARD_HEADER_SIZE
|
764
|
+
raise "Short read for DB response header: " +
|
765
|
+
"expected #{STANDARD_HEADER_SIZE} bytes, saw #{bytes_read}"
|
766
|
+
end
|
767
|
+
nil
|
768
|
+
end
|
766
769
|
|
767
770
|
def receive_response_header(sock)
|
768
|
-
header_buf =
|
769
|
-
header_buf.put_array(receive_message_on_socket(RESPONSE_HEADER_SIZE, sock).unpack("C*"))
|
771
|
+
header_buf = receive_message_on_socket(RESPONSE_HEADER_SIZE, sock)
|
770
772
|
if header_buf.length != RESPONSE_HEADER_SIZE
|
771
773
|
raise "Short read for DB response header; " +
|
772
774
|
"expected #{RESPONSE_HEADER_SIZE} bytes, saw #{header_buf.length}"
|
773
775
|
end
|
774
|
-
header_buf.
|
775
|
-
check_response_flags(
|
776
|
-
cursor_id
|
777
|
-
starting_from = header_buf.get_int
|
778
|
-
number_remaining = header_buf.get_int
|
776
|
+
flags, cursor_id_a, cursor_id_b, starting_from, number_remaining = header_buf.unpack('VVVVV')
|
777
|
+
check_response_flags(flags)
|
778
|
+
cursor_id = (cursor_id_b << 32) + cursor_id_a
|
779
779
|
[number_remaining, cursor_id]
|
780
780
|
end
|
781
781
|
|
@@ -792,13 +792,10 @@ module Mongo
|
|
792
792
|
docs = []
|
793
793
|
number_remaining = number_received
|
794
794
|
while number_remaining > 0 do
|
795
|
-
buf =
|
796
|
-
buf.
|
797
|
-
buf
|
798
|
-
size = buf.get_int
|
799
|
-
buf.put_array(receive_message_on_socket(size - 4, sock).unpack("C*"), 4)
|
795
|
+
buf = receive_message_on_socket(4, sock)
|
796
|
+
size = buf.unpack('V')[0]
|
797
|
+
buf << receive_message_on_socket(size - 4, sock)
|
800
798
|
number_remaining -= 1
|
801
|
-
buf.rewind
|
802
799
|
docs << BSON::BSON_CODER.deserialize(buf)
|
803
800
|
end
|
804
801
|
[docs, number_received, cursor_id]
|
@@ -818,26 +815,27 @@ module Mongo
|
|
818
815
|
opts.assert_valid_keys(:w, :wtimeout, :fsync)
|
819
816
|
cmd.merge!(opts)
|
820
817
|
end
|
821
|
-
message.
|
818
|
+
message.put_binary(BSON::BSON_CODER.serialize(cmd, false).to_s)
|
822
819
|
add_message_headers(Mongo::Constants::OP_QUERY, message)
|
823
820
|
end
|
824
821
|
|
825
822
|
# Prepares a message for transmission to MongoDB by
|
826
823
|
# constructing a valid message header.
|
827
824
|
def add_message_headers(operation, message)
|
828
|
-
headers =
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
825
|
+
headers = [
|
826
|
+
# Message size.
|
827
|
+
16 + message.size,
|
828
|
+
|
829
|
+
# Unique request id.
|
830
|
+
get_request_id,
|
831
|
+
|
832
|
+
# Response id.
|
833
|
+
0,
|
834
|
+
|
835
|
+
# Opcode.
|
836
|
+
operation
|
837
|
+
].pack('VVVV')
|
838
|
+
|
841
839
|
message.prepend!(headers)
|
842
840
|
end
|
843
841
|
|
@@ -847,11 +845,14 @@ module Mongo
|
|
847
845
|
# @return [Integer] number of bytes sent
|
848
846
|
def send_message_on_socket(packed_message, socket)
|
849
847
|
begin
|
850
|
-
total_bytes_sent = 0
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
848
|
+
total_bytes_sent = socket.send(packed_message, 0)
|
849
|
+
if total_bytes_sent != packed_message.size
|
850
|
+
packed_message.slice!(0, total_bytes_sent)
|
851
|
+
while packed_message.size > 0
|
852
|
+
byte_sent = socket.send(packed_message, 0)
|
853
|
+
total_bytes_sent += byte_sent
|
854
|
+
packed_message.slice!(0, byte_sent)
|
855
|
+
end
|
855
856
|
end
|
856
857
|
total_bytes_sent
|
857
858
|
rescue => ex
|
@@ -863,12 +864,16 @@ module Mongo
|
|
863
864
|
# Low-level method for receiving data from socket.
|
864
865
|
# Requires length and an available socket.
|
865
866
|
def receive_message_on_socket(length, socket)
|
866
|
-
message = ""
|
867
867
|
begin
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
868
|
+
message = socket.read(length)
|
869
|
+
raise ConnectionFailure, "connection closed" unless message.length > 0
|
870
|
+
if message.length < length
|
871
|
+
chunk = new_binary_string
|
872
|
+
while message.length < length
|
873
|
+
socket.read(length - message.length, chunk)
|
874
|
+
raise ConnectionFailure, "connection closed" unless chunk.length > 0
|
875
|
+
message << chunk
|
876
|
+
end
|
872
877
|
end
|
873
878
|
rescue => ex
|
874
879
|
close
|
@@ -876,5 +881,40 @@ module Mongo
|
|
876
881
|
end
|
877
882
|
message
|
878
883
|
end
|
884
|
+
|
885
|
+
# Low-level data for receiving data from socket.
|
886
|
+
# Unlike #receive_message_on_socket, this method immediately discards the data
|
887
|
+
# and only returns the number of bytes read.
|
888
|
+
def receive_and_discard_message_on_socket(length, socket)
|
889
|
+
bytes_read = 0
|
890
|
+
begin
|
891
|
+
chunk = socket.read(length)
|
892
|
+
bytes_read = chunk.length
|
893
|
+
raise ConnectionFailure, "connection closed" unless bytes_read > 0
|
894
|
+
if bytes_read < length
|
895
|
+
while bytes_read < length
|
896
|
+
socket.read(length - bytes_read, chunk)
|
897
|
+
raise ConnectionFailure, "connection closed" unless chunk.length > 0
|
898
|
+
bytes_read += chunk.length
|
899
|
+
end
|
900
|
+
end
|
901
|
+
rescue => ex
|
902
|
+
close
|
903
|
+
raise ConnectionFailure, "Operation failed with the following exception: #{ex}"
|
904
|
+
end
|
905
|
+
bytes_read
|
906
|
+
end
|
907
|
+
|
908
|
+
if defined?(Encoding)
|
909
|
+
BINARY_ENCODING = Encoding.find("binary")
|
910
|
+
|
911
|
+
def new_binary_string
|
912
|
+
"".force_encoding(BINARY_ENCODING)
|
913
|
+
end
|
914
|
+
else
|
915
|
+
def new_binary_string
|
916
|
+
""
|
917
|
+
end
|
918
|
+
end
|
879
919
|
end
|
880
920
|
end
|
data/lib/mongo/cursor.rb
CHANGED
@@ -37,6 +37,7 @@ module Mongo
|
|
37
37
|
@db = collection.db
|
38
38
|
@collection = collection
|
39
39
|
@connection = @db.connection
|
40
|
+
@logger = @connection.logger
|
40
41
|
|
41
42
|
@selector = convert_selector_for_query(options[:selector])
|
42
43
|
@fields = convert_fields_for_query(options[:fields])
|
@@ -49,19 +50,20 @@ module Mongo
|
|
49
50
|
@explain = options[:explain]
|
50
51
|
@socket = options[:socket]
|
51
52
|
@tailable = options[:tailable] || false
|
52
|
-
|
53
|
+
batch_size(options[:batch_size] || 0)
|
53
54
|
|
54
55
|
@full_collection_name = "#{@collection.db.name}.#{@collection.name}"
|
55
|
-
@cache
|
56
|
-
@closed
|
57
|
-
@query_run
|
56
|
+
@cache = []
|
57
|
+
@closed = false
|
58
|
+
@query_run = false
|
59
|
+
@returned = 0
|
58
60
|
end
|
59
61
|
|
60
62
|
# Get the next document specified the cursor options.
|
61
63
|
#
|
62
64
|
# @return [Hash, Nil] the next document or Nil if no documents remain.
|
63
65
|
def next_document
|
64
|
-
|
66
|
+
refresh if @cache.length == 0#empty?# num_remaining == 0
|
65
67
|
doc = @cache.shift
|
66
68
|
|
67
69
|
if doc && doc['$err']
|
@@ -178,6 +180,26 @@ module Mongo
|
|
178
180
|
self
|
179
181
|
end
|
180
182
|
|
183
|
+
# Set the batch size for server responses.
|
184
|
+
#
|
185
|
+
# Note that the batch size will take effect only on queries
|
186
|
+
# where the number to be returned is greater than 100.
|
187
|
+
#
|
188
|
+
# @param [Integer] size either 0 or some integer greater than 1. If 0,
|
189
|
+
# the server will determine the batch size.
|
190
|
+
#
|
191
|
+
# @return [Cursor]
|
192
|
+
def batch_size(size=0)
|
193
|
+
check_modifiable
|
194
|
+
if size < 0 || size == 1
|
195
|
+
raise ArgumentError, "Invalid value for batch_size #{size}; must be 0 or > 1."
|
196
|
+
else
|
197
|
+
@batch_size = size > @limit ? @limit : size
|
198
|
+
end
|
199
|
+
|
200
|
+
self
|
201
|
+
end
|
202
|
+
|
181
203
|
# Iterate over each document in this cursor, yielding it to the given
|
182
204
|
# block.
|
183
205
|
#
|
@@ -190,10 +212,11 @@ module Mongo
|
|
190
212
|
# puts doc['user']
|
191
213
|
# end
|
192
214
|
def each
|
193
|
-
num_returned = 0
|
194
|
-
while has_next? && (@limit <= 0 || num_returned < @limit)
|
195
|
-
|
196
|
-
|
215
|
+
#num_returned = 0
|
216
|
+
#while has_next? && (@limit <= 0 || num_returned < @limit)
|
217
|
+
while doc = next_document
|
218
|
+
yield doc #next_document
|
219
|
+
#num_returned += 1
|
197
220
|
end
|
198
221
|
end
|
199
222
|
|
@@ -241,7 +264,8 @@ module Mongo
|
|
241
264
|
message = BSON::ByteBuffer.new([0, 0, 0, 0])
|
242
265
|
message.put_int(1)
|
243
266
|
message.put_long(@cursor_id)
|
244
|
-
@
|
267
|
+
@logger.debug("MONGODB cursor.close #{@cursor_id}") if @logger
|
268
|
+
@connection.send_message(Mongo::Constants::OP_KILL_CURSORS, message, nil)
|
245
269
|
end
|
246
270
|
@cursor_id = 0
|
247
271
|
@closed = true
|
@@ -297,9 +321,7 @@ module Mongo
|
|
297
321
|
{fields => 1}
|
298
322
|
when Array
|
299
323
|
return nil if fields.length.zero?
|
300
|
-
|
301
|
-
fields.each { |field| hash[field] = 1 }
|
302
|
-
end
|
324
|
+
fields.each_with_object({}) { |field, hash| hash[field] = 1 }
|
303
325
|
when Hash
|
304
326
|
return fields
|
305
327
|
end
|
@@ -325,13 +347,13 @@ module Mongo
|
|
325
347
|
end
|
326
348
|
end
|
327
349
|
|
328
|
-
# Return
|
350
|
+
# Return the number of documents remaining for this cursor.
|
329
351
|
def num_remaining
|
330
|
-
|
352
|
+
refresh if @cache.length == 0
|
331
353
|
@cache.length
|
332
354
|
end
|
333
355
|
|
334
|
-
def
|
356
|
+
def refresh
|
335
357
|
return if send_initial_query || @cursor_id.zero?
|
336
358
|
message = BSON::ByteBuffer.new([0, 0, 0, 0])
|
337
359
|
|
@@ -339,11 +361,22 @@ module Mongo
|
|
339
361
|
BSON::BSON_RUBY.serialize_cstr(message, "#{@db.name}.#{@collection.name}")
|
340
362
|
|
341
363
|
# Number of results to return.
|
342
|
-
|
364
|
+
if @limit > 0
|
365
|
+
limit = @limit - @returned
|
366
|
+
if @batch_size > 0
|
367
|
+
limit = limit < @batch_size ? limit : @batch_size
|
368
|
+
end
|
369
|
+
message.put_int(limit)
|
370
|
+
else
|
371
|
+
message.put_int(@batch_size)
|
372
|
+
end
|
343
373
|
|
344
374
|
# Cursor id.
|
345
375
|
message.put_long(@cursor_id)
|
346
|
-
|
376
|
+
@logger.debug("MONGODB cursor.refresh() for cursor #{@cursor_id}") if @logger
|
377
|
+
results, @n_received, @cursor_id = @connection.receive_message(Mongo::Constants::OP_GET_MORE,
|
378
|
+
message, nil, @socket)
|
379
|
+
@returned += @n_received
|
347
380
|
@cache += results
|
348
381
|
close_cursor_if_query_complete
|
349
382
|
end
|
@@ -354,8 +387,9 @@ module Mongo
|
|
354
387
|
false
|
355
388
|
else
|
356
389
|
message = construct_query_message
|
357
|
-
|
358
|
-
|
390
|
+
@logger.debug query_log_message if @logger
|
391
|
+
results, @n_received, @cursor_id = @connection.receive_message(Mongo::Constants::OP_QUERY, message, nil, @socket)
|
392
|
+
@returned += @n_received
|
359
393
|
@cache += results
|
360
394
|
@query_run = true
|
361
395
|
close_cursor_if_query_complete
|
@@ -370,8 +404,8 @@ module Mongo
|
|
370
404
|
message.put_int(@skip)
|
371
405
|
message.put_int(@limit)
|
372
406
|
spec = query_contains_special_fields? ? construct_query_spec : @selector
|
373
|
-
message.
|
374
|
-
message.
|
407
|
+
message.put_binary(BSON::BSON_CODER.serialize(spec, false).to_s)
|
408
|
+
message.put_binary(BSON::BSON_CODER.serialize(@fields, false).to_s) if @fields
|
375
409
|
message
|
376
410
|
end
|
377
411
|
|
@@ -402,7 +436,9 @@ module Mongo
|
|
402
436
|
end
|
403
437
|
|
404
438
|
def close_cursor_if_query_complete
|
405
|
-
|
439
|
+
if @limit > 0 && @returned >= @limit
|
440
|
+
close
|
441
|
+
end
|
406
442
|
end
|
407
443
|
|
408
444
|
def check_modifiable
|
data/lib/mongo/util/core_ext.rb
CHANGED
@@ -20,10 +20,21 @@
|
|
20
20
|
class Object
|
21
21
|
|
22
22
|
#:nodoc:
|
23
|
-
def
|
24
|
-
yield
|
25
|
-
|
26
|
-
end
|
23
|
+
def tap
|
24
|
+
yield self
|
25
|
+
self
|
26
|
+
end unless respond_to? :tap
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
#:nodoc:
|
31
|
+
module Enumerable
|
32
|
+
|
33
|
+
#:nodoc:
|
34
|
+
def each_with_object(memo)
|
35
|
+
each { |element| yield(element, memo) }
|
36
|
+
memo
|
37
|
+
end unless [].respond_to?(:each_with_object)
|
27
38
|
|
28
39
|
end
|
29
40
|
|
data/mongo.gemspec
CHANGED
@@ -15,8 +15,11 @@ Gem::Specification.new do |s|
|
|
15
15
|
'mongo.gemspec', 'LICENSE.txt']
|
16
16
|
s.files += ['lib/mongo.rb'] + Dir['lib/mongo/**/*.rb']
|
17
17
|
s.files += Dir['examples/**/*.rb'] + Dir['bin/**/*.rb']
|
18
|
+
s.files += Dir['bin/mongo_console']
|
18
19
|
s.test_files = Dir['test/**/*.rb']
|
19
20
|
|
21
|
+
s.executables = ['mongo_console']
|
22
|
+
|
20
23
|
s.has_rdoc = true
|
21
24
|
s.test_files = Dir['test/**/*.rb']
|
22
25
|
s.test_files -= Dir['test/mongo_bson/*.rb'] # remove these files from the manifest
|
@@ -1,7 +1,7 @@
|
|
1
1
|
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
2
|
require 'mongo'
|
3
3
|
require 'test/unit'
|
4
|
-
require 'test/test_helper'
|
4
|
+
require './test/test_helper'
|
5
5
|
|
6
6
|
# NOTE: This test requires bouncing the server.
|
7
7
|
# It also requires that a user exists on the admin database.
|
data/test/collection_test.rb
CHANGED
@@ -105,10 +105,11 @@ class TestCollection < Test::Unit::TestCase
|
|
105
105
|
end
|
106
106
|
|
107
107
|
def test_safe_insert
|
108
|
+
@@test.create_index("hello", :unique => true)
|
108
109
|
a = {"hello" => "world"}
|
109
110
|
@@test.insert(a)
|
110
111
|
@@test.insert(a)
|
111
|
-
assert(@@db.
|
112
|
+
assert(@@db.get_last_error['err'].include?("11000"))
|
112
113
|
|
113
114
|
assert_raise OperationFailure do
|
114
115
|
@@test.insert(a, :safe => true)
|
data/test/connection_test.rb
CHANGED
data/test/conversions_test.rb
CHANGED
data/test/cursor_fail_test.rb
CHANGED
data/test/cursor_message_test.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'test/test_helper'
|
1
|
+
require './test/test_helper'
|
2
2
|
require 'logger'
|
3
3
|
|
4
4
|
class CursorTest < Test::Unit::TestCase
|
@@ -17,16 +17,28 @@ class CursorTest < Test::Unit::TestCase
|
|
17
17
|
@@coll_full_name = "#{MONGO_TEST_DB}.test"
|
18
18
|
end
|
19
19
|
|
20
|
-
def
|
21
|
-
|
22
|
-
@@coll.
|
20
|
+
def test_valid_batch_sizes
|
21
|
+
assert_raise ArgumentError do
|
22
|
+
@@coll.find({}, :batch_size => 1, :limit => 5)
|
23
23
|
end
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
25
|
+
assert_raise ArgumentError do
|
26
|
+
@@coll.find({}, :batch_size => -1, :limit => 5)
|
27
|
+
end
|
28
|
+
|
29
|
+
assert @@coll.find({}, :batch_size => 0, :limit => 5)
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_batch_size
|
33
|
+
@@coll.remove
|
34
|
+
200.times do |n|
|
35
|
+
@@coll.insert({:a => n})
|
36
|
+
end
|
37
|
+
|
38
|
+
list = @@coll.find({}, :batch_size => 2, :limit => 6).to_a
|
39
|
+
assert_equal 6, list.length
|
40
|
+
|
41
|
+
list = @@coll.find({}, :batch_size => 100, :limit => 101).to_a
|
42
|
+
assert_equal 101, list.length
|
31
43
|
end
|
32
44
|
end
|
data/test/cursor_test.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'test/test_helper'
|
1
|
+
require './test/test_helper'
|
2
2
|
require 'logger'
|
3
3
|
|
4
4
|
class CursorTest < Test::Unit::TestCase
|
@@ -126,13 +126,13 @@ class CursorTest < Test::Unit::TestCase
|
|
126
126
|
@@coll.remove
|
127
127
|
|
128
128
|
t1 = Time.now
|
129
|
-
t1_id =
|
129
|
+
t1_id = ObjectId.from_time(t1)
|
130
130
|
@@coll.save({:t => 't1'})
|
131
131
|
@@coll.save({:t => 't1'})
|
132
132
|
@@coll.save({:t => 't1'})
|
133
133
|
sleep(2)
|
134
134
|
t2 = Time.now
|
135
|
-
t2_id =
|
135
|
+
t2_id = ObjectId.from_time(t2)
|
136
136
|
@@coll.save({:t => 't2'})
|
137
137
|
@@coll.save({:t => 't2'})
|
138
138
|
@@coll.save({:t => 't2'})
|
@@ -428,4 +428,5 @@ class CursorTest < Test::Unit::TestCase
|
|
428
428
|
cursor.rewind!
|
429
429
|
assert_equal 100, cursor.map {|doc| doc }.length
|
430
430
|
end
|
431
|
-
|
431
|
+
|
432
|
+
end
|
data/test/db_api_test.rb
CHANGED
data/test/db_connection_test.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'test/test_helper'
|
1
|
+
require './test/test_helper'
|
2
2
|
|
3
3
|
class DBConnectionTest < Test::Unit::TestCase
|
4
4
|
|
@@ -10,6 +10,6 @@ class DBConnectionTest < Test::Unit::TestCase
|
|
10
10
|
db = Connection.new(host, port).db(MONGO_TEST_DB)
|
11
11
|
coll = db.collection('test')
|
12
12
|
coll.remove
|
13
|
-
db.
|
13
|
+
db.get_last_error
|
14
14
|
end
|
15
15
|
end
|
data/test/db_test.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
require 'test/test_helper'
|
1
|
+
require './test/test_helper'
|
3
2
|
require 'digest/md5'
|
4
3
|
require 'stringio'
|
5
4
|
require 'logger'
|
@@ -204,10 +203,10 @@ class DBTest < Test::Unit::TestCase
|
|
204
203
|
@@db['test'].save("i" => 1)
|
205
204
|
|
206
205
|
@@db['test'].update({"i" => 1}, {"$set" => {"i" => 2}})
|
207
|
-
assert @@db.
|
206
|
+
assert @@db.get_last_error()["updatedExisting"]
|
208
207
|
|
209
208
|
@@db['test'].update({"i" => 1}, {"$set" => {"i" => 500}})
|
210
|
-
assert !@@db.
|
209
|
+
assert !@@db.get_last_error()["updatedExisting"]
|
211
210
|
end
|
212
211
|
|
213
212
|
def test_text_port_number_raises_no_errors
|
data/test/grid_io_test.rb
CHANGED
data/test/grid_test.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'test/test_helper'
|
1
|
+
require './test/test_helper'
|
2
2
|
include Mongo
|
3
3
|
|
4
4
|
class GridTest < Test::Unit::TestCase
|
@@ -139,7 +139,7 @@ class GridTest < Test::Unit::TestCase
|
|
139
139
|
io.rewind
|
140
140
|
data = io.read
|
141
141
|
if data.respond_to?(:force_encoding)
|
142
|
-
data.force_encoding(
|
142
|
+
data.force_encoding("binary")
|
143
143
|
end
|
144
144
|
read_data = ""
|
145
145
|
while(chunk = file.read(read_length))
|
@@ -1,7 +1,7 @@
|
|
1
1
|
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
2
|
require 'mongo'
|
3
3
|
require 'test/unit'
|
4
|
-
require 'test/test_helper'
|
4
|
+
require './test/test_helper'
|
5
5
|
|
6
6
|
# NOTE: this test should be run only if a replica pair is running.
|
7
7
|
class ReplicaPairCountTest < Test::Unit::TestCase
|
@@ -1,7 +1,7 @@
|
|
1
1
|
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
2
|
require 'mongo'
|
3
3
|
require 'test/unit'
|
4
|
-
require 'test/test_helper'
|
4
|
+
require './test/test_helper'
|
5
5
|
|
6
6
|
# NOTE: this test should be run only if a replica pair is running.
|
7
7
|
class ReplicaPairInsertTest < Test::Unit::TestCase
|
@@ -1,7 +1,7 @@
|
|
1
1
|
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
2
|
require 'mongo'
|
3
3
|
require 'test/unit'
|
4
|
-
require 'test/test_helper'
|
4
|
+
require './test/test_helper'
|
5
5
|
|
6
6
|
# NOTE: this test should be run only if a replica pair is running.
|
7
7
|
class ReplicaPairPooledInsertTest < Test::Unit::TestCase
|
@@ -1,7 +1,7 @@
|
|
1
1
|
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
2
|
require 'mongo'
|
3
3
|
require 'test/unit'
|
4
|
-
require 'test/test_helper'
|
4
|
+
require './test/test_helper'
|
5
5
|
|
6
6
|
# NOTE: this test should be run only if a replica pair is running.
|
7
7
|
class ReplicaPairQueryTest < Test::Unit::TestCase
|
@@ -1,7 +1,7 @@
|
|
1
1
|
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
2
|
require 'mongo'
|
3
3
|
require 'test/unit'
|
4
|
-
require 'test/test_helper'
|
4
|
+
require './test/test_helper'
|
5
5
|
|
6
6
|
# NOTE: This test expects a replica set of three nodes, one of which is an arbiter, to be running
|
7
7
|
# on the local host.
|
@@ -1,7 +1,7 @@
|
|
1
1
|
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
2
|
require 'mongo'
|
3
3
|
require 'test/unit'
|
4
|
-
require 'test/test_helper'
|
4
|
+
require './test/test_helper'
|
5
5
|
|
6
6
|
# NOTE: This test expects a replica set of three nodes to be running on local host.
|
7
7
|
class ReplicaSetAckTest < Test::Unit::TestCase
|
data/test/support_test.rb
CHANGED
data/test/threading_test.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'test/test_helper'
|
1
|
+
require File.expand_path('./test/test_helper.rb')
|
2
2
|
|
3
3
|
class CollectionTest < Test::Unit::TestCase
|
4
4
|
|
@@ -12,8 +12,9 @@ class CollectionTest < Test::Unit::TestCase
|
|
12
12
|
@db = @conn['testing']
|
13
13
|
@coll = @db.collection('books')
|
14
14
|
@conn.expects(:send_message).with do |op, msg, log|
|
15
|
-
op == 2001
|
15
|
+
op == 2001
|
16
16
|
end
|
17
|
+
@logger.stubs(:debug)
|
17
18
|
@coll.update({}, {:title => 'Moby Dick'})
|
18
19
|
end
|
19
20
|
|
@@ -22,7 +23,10 @@ class CollectionTest < Test::Unit::TestCase
|
|
22
23
|
@db = @conn['testing']
|
23
24
|
@coll = @db.collection('books')
|
24
25
|
@conn.expects(:send_message).with do |op, msg, log|
|
25
|
-
op == 2002
|
26
|
+
op == 2002
|
27
|
+
end
|
28
|
+
@logger.expects(:debug).with do |msg|
|
29
|
+
msg.include?("Moby")
|
26
30
|
end
|
27
31
|
@coll.insert({:title => 'Moby Dick'})
|
28
32
|
end
|
@@ -32,8 +36,11 @@ class CollectionTest < Test::Unit::TestCase
|
|
32
36
|
@db = @conn['testing']
|
33
37
|
@coll = @db.collection('books')
|
34
38
|
@conn.expects(:receive_message).with do |op, msg, log, sock|
|
35
|
-
op == 2004
|
39
|
+
op == 2004
|
36
40
|
end.returns([[], 0, 0])
|
41
|
+
@logger.expects(:debug).with do |msg|
|
42
|
+
msg.include?('Moby')
|
43
|
+
end
|
37
44
|
@coll.find({:title => 'Moby Dick'}).sort([['title', 1], ['author', 1]]).next_document
|
38
45
|
end
|
39
46
|
|
@@ -43,7 +50,10 @@ class CollectionTest < Test::Unit::TestCase
|
|
43
50
|
@coll = @db.collection('books')
|
44
51
|
data = BSON::Binary.new(("BINARY " * 1000).unpack("c*"))
|
45
52
|
@conn.expects(:send_message).with do |op, msg, log|
|
46
|
-
op == 2002
|
53
|
+
op == 2002
|
54
|
+
end
|
55
|
+
@logger.expects(:debug).with do |msg|
|
56
|
+
msg.include?("Binary")
|
47
57
|
end
|
48
58
|
@coll.insert({:data => data})
|
49
59
|
end
|
@@ -53,7 +63,10 @@ class CollectionTest < Test::Unit::TestCase
|
|
53
63
|
@db = @conn['testing']
|
54
64
|
@coll = @db.collection('books')
|
55
65
|
@conn.expects(:send_message_with_safe_check).with do |op, msg, db_name, log|
|
56
|
-
op == 2001
|
66
|
+
op == 2001
|
67
|
+
end
|
68
|
+
@logger.expects(:debug).with do |msg|
|
69
|
+
msg.include?("testing['books'].update")
|
57
70
|
end
|
58
71
|
@coll.update({}, {:title => 'Moby Dick'}, :safe => true)
|
59
72
|
end
|
@@ -63,8 +76,9 @@ class CollectionTest < Test::Unit::TestCase
|
|
63
76
|
@db = @conn['testing']
|
64
77
|
@coll = @db.collection('books')
|
65
78
|
@conn.expects(:send_message_with_safe_check).with do |op, msg, db_name, log|
|
66
|
-
op == 2001
|
79
|
+
op == 2001
|
67
80
|
end
|
81
|
+
@logger.stubs(:debug)
|
68
82
|
@coll.update({}, {:title => 'Moby Dick'}, :safe => true)
|
69
83
|
end
|
70
84
|
end
|
data/test/unit/cursor_test.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
-
require 'test/test_helper'
|
1
|
+
require './test/test_helper'
|
2
2
|
|
3
3
|
class CursorTest < Test::Unit::TestCase
|
4
4
|
context "Cursor options" do
|
5
5
|
setup do
|
6
|
-
@
|
6
|
+
@logger = mock()
|
7
|
+
@logger.stubs(:debug)
|
8
|
+
@connection = stub(:class => Connection, :logger => @logger)
|
7
9
|
@db = stub(:name => "testing", :slave_ok? => false, :connection => @connection)
|
8
10
|
@collection = stub(:db => @db, :name => "items")
|
9
11
|
@cursor = Cursor.new(@collection)
|
@@ -70,7 +72,7 @@ class CursorTest < Test::Unit::TestCase
|
|
70
72
|
|
71
73
|
context "Query fields" do
|
72
74
|
setup do
|
73
|
-
@connection = stub(:class => Collection)
|
75
|
+
@connection = stub(:class => Collection, :logger => @logger)
|
74
76
|
@db = stub(:slave_ok? => true, :name => "testing", :connection => @connection)
|
75
77
|
@collection = stub(:db => @db, :name => "items")
|
76
78
|
end
|
data/test/unit/db_test.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'test/test_helper'
|
1
|
+
require './test/test_helper'
|
2
2
|
|
3
3
|
class DBTest < Test::Unit::TestCase
|
4
4
|
context "DBTest: " do
|
@@ -71,7 +71,7 @@ class DBTest < Test::Unit::TestCase
|
|
71
71
|
should "raise an error if getlasterror fails" do
|
72
72
|
@db.expects(:command).returns({})
|
73
73
|
assert_raise Mongo::MongoDBError do
|
74
|
-
@db.
|
74
|
+
@db.get_last_error
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 5
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 9
|
10
|
+
version: 1.0.9
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jim Menard
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2010-
|
20
|
+
date: 2010-09-20 00:00:00 -04:00
|
21
21
|
default_executable:
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|
@@ -38,8 +38,8 @@ dependencies:
|
|
38
38
|
version_requirements: *id001
|
39
39
|
description: A Ruby driver for MongoDB. For more information about Mongo, see http://www.mongodb.org.
|
40
40
|
email: mongodb-dev@googlegroups.com
|
41
|
-
executables:
|
42
|
-
|
41
|
+
executables:
|
42
|
+
- mongo_console
|
43
43
|
extensions: []
|
44
44
|
|
45
45
|
extra_rdoc_files:
|
@@ -76,6 +76,9 @@ files:
|
|
76
76
|
- examples/types.rb
|
77
77
|
- bin/bson_benchmark.rb
|
78
78
|
- bin/fail_if_no_c.rb
|
79
|
+
- bin/insert.rb
|
80
|
+
- bin/oid.rb
|
81
|
+
- bin/mongo_console
|
79
82
|
- test/auxillary/1.4_features.rb
|
80
83
|
- test/auxillary/authentication_test.rb
|
81
84
|
- test/auxillary/autoreconnect_test.rb
|