-
Type: Improvement
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
-
Minor Change
We have this failing test now on latest server:
1) ./spec/mongo/collection/view/readable_spec.rb[1:7:2:3:1] Mongo::Collection::View::Readable#distinct when a selector is provided when the field is nil returns an empty array Mongo::Error::OperationFailure: FieldPath cannot be constructed with empty string (40352) (on localhost:27018, attempt 1) (on localhost:27018, attempt 1) /data/mci/84f7f9158a4bd026f9c5d5a5ce96a57b/src/lib/mongo/operation/result.rb:297:in `raise_operation_failure' /data/mci/84f7f9158a4bd026f9c5d5a5ce96a57b/src/lib/mongo/operation/result.rb:268:in `validate!' /data/mci/84f7f9158a4bd026f9c5d5a5ce96a57b/src/lib/mongo/operation/shared/response_handling.rb:29:in `block (3 levels) in validate_result' /data/mci/84f7f9158a4bd026f9c5d5a5ce96a57b/src/lib/mongo/operation/shared/response_handling.rb:87:in `add_server_diagnostics' /data/mci/84f7f9158a4bd026f9c5d5a5ce96a57b/src/lib/mongo/operation/shared/response_handling.rb:28:in `block (2 levels) in validate_result' /data/mci/84f7f9158a4bd026f9c5d5a5ce96a57b/src/lib/mongo/operation/shared/response_handling.rb:43:in `add_error_labels' /data/mci/84f7f9158a4bd026f9c5d5a5ce96a57b/src/lib/mongo/operation/shared/response_handling.rb:27:in `block in validate_result' /data/mci/84f7f9158a4bd026f9c5d5a5ce96a57b/src/lib/mongo/operation/shared/response_handling.rb:73:in `unpin_maybe' /data/mci/84f7f9158a4bd026f9c5d5a5ce96a57b/src/lib/mongo/operation/shared/response_handling.rb:26:in `validate_result' /data/mci/84f7f9158a4bd026f9c5d5a5ce96a57b/src/lib/mongo/operation/shared/executable.rb:39:in `block in execute' /data/mci/84f7f9158a4bd026f9c5d5a5ce96a57b/src/lib/mongo/operation/shared/executable.rb:38:in `tap' /data/mci/84f7f9158a4bd026f9c5d5a5ce96a57b/src/lib/mongo/operation/shared/executable.rb:38:in `execute' /data/mci/84f7f9158a4bd026f9c5d5a5ce96a57b/src/lib/mongo/operation/shared/op_msg_or_command.rb:27:in `execute' /data/mci/84f7f9158a4bd026f9c5d5a5ce96a57b/src/lib/mongo/collection/view/readable.rb:267:in `block (2 levels) in distinct' /data/mci/84f7f9158a4bd026f9c5d5a5ce96a57b/src/lib/mongo/retryable.rb:304:in `modern_read_with_retry' /data/mci/84f7f9158a4bd026f9c5d5a5ce96a57b/src/lib/mongo/retryable.rb:117:in `read_with_retry' /data/mci/84f7f9158a4bd026f9c5d5a5ce96a57b/src/rubies/ruby-2.6.3/lib/ruby/2.6.0/forwardable.rb:230:in `read_with_retry' /data/mci/84f7f9158a4bd026f9c5d5a5ce96a57b/src/lib/mongo/collection/view/readable.rb:259:in `block in distinct' /data/mci/84f7f9158a4bd026f9c5d5a5ce96a57b/src/lib/mongo/cluster.rb:799:in `with_session' /data/mci/84f7f9158a4bd026f9c5d5a5ce96a57b/src/lib/mongo/client.rb:829:in `with_session' /data/mci/84f7f9158a4bd026f9c5d5a5ce96a57b/src/lib/mongo/collection/view.rb:208:in `with_session' /data/mci/84f7f9158a4bd026f9c5d5a5ce96a57b/src/lib/mongo/collection/view/readable.rb:258:in `distinct' /data/mci/84f7f9158a4bd026f9c5d5a5ce96a57b/src/spec/mongo/collection/view/readable_spec.rb:641:in `block (5 levels) in <top (required)>'
The documentation for distinct on server (https://docs.mongodb.com/manual/reference/method/db.collection.distinct/) does not say anything about omitting the field/key. It says "Finds the distinct values for a specified field across a single collection or view and returns the results in an array." implying the field/key is required. Ruby driver used to allow a nil key, which resulted in an empty key being sent to the server, which worked until recently:
ruby-driver-rs:PRIMARY> db.ofo.distinct('a')
[ ]
... but no longer works. The Ruby driver documentation already states that key must be a string or a symbol, not nil. I propose we prohibit nil keys since it does not appear to be a legitimate use of distinct.
- related to
-
SERVER-43613 "FieldPath cannot be constructed with empty string (40352)" message does not refer to user input
- Backlog
-
RUBY-1724 Run tests latest server version
- Closed
- links to