Skip to content

Commit 2560451

Browse files
RUBY-2902 send comment explicitly in GetMore (#2425)
1 parent c98e297 commit 2560451

File tree

5 files changed

+57
-8
lines changed

5 files changed

+57
-8
lines changed

lib/mongo/cursor.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,11 @@ def get_more_operation
423423
else
424424
nil
425425
end,
426+
comment: if view.respond_to?(:options) && view.options.is_a?(Hash)
427+
view.options[:comment]
428+
else
429+
nil
430+
end,
426431
}
427432
Operation::GetMore.new(spec)
428433
end

lib/mongo/operation/get_more/command_builder.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def selector(connection)
3030
collection: spec.fetch(:coll_name),
3131
batchSize: spec[:batch_size],
3232
maxTimeMS: spec[:max_time_ms],
33+
comment: spec[:comment],
3334
}.compact
3435
end
3536
end

spec/spec_tests/data/change_streams_unified/change-streams.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,44 @@ tests:
136136
pipeline:
137137
- $changeStream: {}
138138
comment: "comment"
139+
140+
- description: "Test that comment is set on getMore"
141+
runOnRequirements:
142+
- minServerVersion: "4.4.0"
143+
topologies: [ single, replicaset ]
144+
operations:
145+
- name: createChangeStream
146+
object: *collection0
147+
arguments:
148+
pipeline: []
149+
comment: "comment"
150+
saveResultAsEntity: &changeStream0 changeStream0
151+
- name: insertOne
152+
object: *collection0
153+
arguments:
154+
document: &new_document
155+
_id: 1
156+
a: 1
157+
- name: iterateUntilDocumentOrError
158+
object: *changeStream0
159+
expectEvents:
160+
- client: *client0
161+
events:
162+
- commandStartedEvent:
163+
command:
164+
aggregate: *collection0
165+
pipeline:
166+
- $changeStream: {}
167+
comment: "comment"
168+
- commandStartedEvent:
169+
command:
170+
insert: *collection0
171+
documents:
172+
- *new_document
173+
- commandStartedEvent:
174+
command:
175+
getMore: { $$type: [ int, long ] }
176+
collection: *collection0
177+
comment: "comment"
178+
commandName: getMore
179+
databaseName: *database0

spec/spec_tests/data/crud_unified/aggregate.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,10 @@ tests:
125125
commandName: aggregate
126126
databaseName: *database0Name
127127

128-
- description: "aggregate with comment does not set comment on getMore"
128+
- description: "aggregate with comment sets comment on getMore"
129129
runOnRequirements:
130-
- minServerVersion: "3.6.0"
130+
- minServerVersion: "4.4.0"
131+
topologies: [ single, replicaset ]
131132
operations:
132133
- name: aggregate
133134
arguments:
@@ -157,14 +158,14 @@ tests:
157158
getMore: { $$type: [ int, long ] }
158159
collection: *collection0Name
159160
batchSize: 2
160-
comment: { $$exists: false }
161+
comment: "comment"
161162
commandName: getMore
162163
databaseName: *database0Name
163164
- commandStartedEvent:
164165
command:
165166
getMore: { $$type: [ int, long ] }
166167
collection: *collection0Name
167168
batchSize: 2
168-
comment: { $$exists: false }
169+
comment: "comment"
169170
commandName: getMore
170171
databaseName: *database0Name

spec/spec_tests/data/crud_unified/find-comment.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,10 @@ tests:
8888
filter: *filter
8989
comment: *comment
9090

91-
- description: "find with comment does not set comment on getMore"
91+
- description: "find with comment sets comment on getMore"
9292
runOnRequirements:
93-
- minServerVersion: "3.6"
93+
- minServerVersion: "4.4.0"
94+
topologies: [ single, replicaset ]
9495
operations:
9596
- name: find
9697
object: *collection0
@@ -118,10 +119,10 @@ tests:
118119
getMore: { $$type: [ int, long ] }
119120
collection: *collection0Name
120121
batchSize: 2
121-
comment: { $$exists: false }
122+
comment: "comment"
122123
- commandStartedEvent:
123124
command:
124125
getMore: { $$type: [ int, long ] }
125126
collection: *collection0Name
126127
batchSize: 2
127-
comment: { $$exists: false }
128+
comment: "comment"

0 commit comments

Comments
 (0)