added sort to query logging RUBY-101
This commit is contained in:
parent
661a0a4120
commit
8faa243484
|
@ -363,7 +363,8 @@ module Mongo
|
|||
|
||||
def query_log_message
|
||||
"#{@admin ? 'admin' : @db.name}.#{@collection.name}.find(#{@selector.inspect}, #{@fields ? @fields.inspect : '{}'})" +
|
||||
"#{@skip != 0 ? ('.skip(' + @skip.to_s + ')') : ''}#{@limit != 0 ? ('.limit(' + @limit.to_s + ')') : ''}"
|
||||
"#{@skip != 0 ? ('.skip(' + @skip.to_s + ')') : ''}#{@limit != 0 ? ('.limit(' + @limit.to_s + ')') : ''}" +
|
||||
"#{@order ? ('.sort(' + @order.inspect + ')') : ''}"
|
||||
end
|
||||
|
||||
def selector_with_special_query_fields
|
||||
|
|
|
@ -27,6 +27,16 @@ class CollectionTest < Test::Unit::TestCase
|
|||
@coll.insert({:title => 'Moby Dick'})
|
||||
end
|
||||
|
||||
should "send sort data" do
|
||||
@conn = Connection.new('localhost', 27017, :logger => @logger, :connect => false)
|
||||
@db = @conn['testing']
|
||||
@coll = @db.collection('books')
|
||||
@conn.expects(:receive_message).with do |op, msg, log, sock|
|
||||
op == 2004 && log.include?("sort")
|
||||
end.returns([[], 0, 0])
|
||||
@coll.find({:title => 'Moby Dick'}).sort([['title', 1], ['author', 1]]).next_document
|
||||
end
|
||||
|
||||
should "not log binary data" do
|
||||
@conn = Connection.new('localhost', 27017, :logger => @logger, :connect => false)
|
||||
@db = @conn['testing']
|
||||
|
|
Loading…
Reference in New Issue