Skip to content

Commit 834f6ee

Browse files
committed
RUBY-1022: Don't error on err/errmsg/ok fields in query doc
1 parent 039c8ec commit 834f6ee

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

lib/mongo/operation/read/query/result.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class Result < Operation::Result
3131
#
3232
# @since 2.0.0
3333
def successful?
34-
!query_failure? && parser.message.empty?
34+
!query_failure?
3535
end
3636
end
3737
end

spec/mongo/collection_spec.rb

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,41 @@
470470
end
471471
end
472472

473+
context 'when the user is not authorized' do
474+
475+
end
476+
477+
context 'when documents contain potential error message fields' do
478+
479+
[ Mongo::Error::ERRMSG, Mongo::Error::ERROR, Mongo::Operation::Result::OK ].each do |field|
480+
481+
context "when the document contains a '#{field}' field" do
482+
483+
let(:value) do
484+
'testing'
485+
end
486+
487+
let(:view) do
488+
authorized_collection.find
489+
end
490+
491+
before do
492+
authorized_collection.insert_one({ field => value })
493+
end
494+
495+
after do
496+
authorized_collection.delete_many
497+
end
498+
499+
it 'iterates over the documents' do
500+
view.each do |document|
501+
expect(document[field]).to eq(value)
502+
end
503+
end
504+
end
505+
end
506+
end
507+
473508
context 'when provided options' do
474509

475510
let(:view) do

0 commit comments

Comments
 (0)