lib/mongo/collection/view/readable.rb in mongo-2.18.3 vs lib/mongo/collection/view/readable.rb in mongo-2.19.0
- old
+ new
@@ -1,7 +1,7 @@
# frozen_string_literal: true
-# encoding: utf-8
+# rubocop:todo all
# Copyright (C) 2014-2020 MongoDB Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -270,22 +270,21 @@
read_with_retry(session, selector) do |server|
context = Operation::Context.new(client: client, session: session)
cmd = { count: collection.name }
cmd[:maxTimeMS] = opts[:max_time_ms] if opts[:max_time_ms]
if read_concern
- cmd[:readConcern] = Options::Mapper.transform_values_to_strings(
- read_concern)
- end
- result = Operation::Count.new(
- selector: cmd,
- db_name: database.name,
- read: read_pref,
- session: session,
- comment: opts[:comment],
- ).execute(server, context: context)
- result.n.to_i
+ cmd[:readConcern] = Options::Mapper.transform_values_to_strings(read_concern)
end
+ result = Operation::Count.new(
+ selector: cmd,
+ db_name: database.name,
+ read: read_pref,
+ session: session,
+ comment: opts[:comment],
+ ).execute(server, context: context)
+ result.n.to_i
end
+ end
rescue Error::OperationFailure => exc
if exc.code == 26
# NamespaceNotFound
# This should only happen with the aggregation pipeline path
# (server 4.9+). Previous servers should return 0 for nonexistent