@@ -256,16 +256,18 @@ defmodule Mongo.MongoDBConnection do
256
256
end
257
257
defp execute_action ( :command , [ cmd ] , opts , % { wire_version: version } = state ) when version >= 6 do
258
258
259
- cmd = cmd ++ [ "$db": opts [ :database ] || state . database ,
260
- "$readPreference": [ mode: update_read_preferences ( opts [ :slave_ok ] ) ] ]
259
+ cmd = cmd ++ [ "$db": opts [ :database ] || state . database , "$readPreference": [ mode: update_read_preferences ( opts [ :slave_ok ] ) ] ]
261
260
262
261
# MongoDB 3.6 only allows certain command arguments to be provided this way. These are:
263
262
op = case pulling_out? ( cmd , :documents ) || pulling_out? ( cmd , :updates ) || pulling_out? ( cmd , :deletes ) do
264
263
nil -> op_msg ( flags: 0 , sections: [ section ( payload_type: 0 , payload: payload ( doc: cmd ) ) ] )
265
264
key -> pulling_out ( cmd , key )
266
265
end
267
266
268
- with { :ok , doc } <- Utils . post_request ( op , state . request_id , state ) ,
267
+ # overwrite temporary timeout by timeout option
268
+ timeout = Keyword . get ( opts , :timeout , state . timeout )
269
+
270
+ with { :ok , doc } <- Utils . post_request ( op , state . request_id , % { state | timeout: timeout } ) ,
269
271
state = % { state | request_id: state . request_id + 1 } do
270
272
{ :ok , doc , state }
271
273
end
@@ -274,8 +276,8 @@ defmodule Mongo.MongoDBConnection do
274
276
275
277
flags = Keyword . take ( opts , @ find_one_flags )
276
278
op = op_query ( coll: Utils . namespace ( "$cmd" , state , opts [ :database ] ) , query: cmd , select: "" , num_skip: 0 , num_return: 1 , flags: flags ( flags ) )
277
-
278
- with { :ok , doc } <- Utils . post_request ( op , state . request_id , state ) ,
279
+ timeout = Keyword . get ( opts , :timeout , state . timeout )
280
+ with { :ok , doc } <- Utils . post_request ( op , state . request_id , % { state | timeout: timeout } ) ,
279
281
state = % { state | request_id: state . request_id + 1 } do
280
282
{ :ok , doc , state }
281
283
end
0 commit comments