mongo 2.21.3 → 2.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aa269cb6bbc5d94255ef1dfb56b4c963304437f9ddcc064b43545485a9892ffa
4
- data.tar.gz: e0fe8f3cadadc8ef70a28d82ea512bd779d9380738bdb814d7d8c8f59618b65d
3
+ metadata.gz: bfc6de88aae51217bcbe02307215fefb67259f3257c5eba94c966fa8ceac5ccd
4
+ data.tar.gz: 258a3151671bf5ef8f6ece898dee5846b767ea5ed537fc2a86699ca688285176
5
5
  SHA512:
6
- metadata.gz: 6819366f273f957c46eb5a9dae0a4de7cfe12f1bfea1fe60c412631650d0337d19e8f543d5608b04e8a2c7c57cb84ce3c5598ccaca0eec0984a8dddc9876c5d8
7
- data.tar.gz: 2aebef8f8d12d6770b5e07cd516909d29762d76352518b7dfa79433d3eaf56fd9871086c8531e4dad21c70829bf268c7f834c2cf9f3bbbbf01fe787a803f2dc3
6
+ metadata.gz: 2c32a72398d175523f643ad4e229f406e82f450d5eb254ee3e05815645750dd578bca77da03ee5c546146c5d78779cced7c97485107589f057fef3fcb1097662
7
+ data.tar.gz: 1b3dfcefc33c710792591177f18ea274439326cac1c525cc13d39c6551ac33582baa579082832422166fd819cfa68815659925d925e34f8a4e1026f244fe63f2
data/lib/mongo/address.rb CHANGED
@@ -237,7 +237,7 @@ module Mongo
237
237
  # (multiple identical items in the returned array). It does not make
238
238
  # sense to try to connect to the same address more than once, thus
239
239
  # eliminate duplicates here.
240
- infos = ::Socket.getaddrinfo(host, nil, family, ::Socket::SOCK_STREAM)
240
+ infos = getaddrinfo(host, family)
241
241
  results = infos.map do |info|
242
242
  [info[4], info[3]]
243
243
  end.uniq
@@ -276,6 +276,12 @@ module Mongo
276
276
 
277
277
  private
278
278
 
279
+ # This is a simple wrapper around Socket.getaddrinfo added to
280
+ # make testing easier.
281
+ def getaddrinfo(host, family)
282
+ ::Socket.getaddrinfo(host, nil, family, ::Socket::SOCK_STREAM)
283
+ end
284
+
279
285
  def parse_host_port
280
286
  address = seed.downcase
281
287
  case address
@@ -305,7 +311,7 @@ module Mongo
305
311
  else
306
312
  raise e
307
313
  end
308
- rescue IOError, SystemCallError => e
314
+ rescue IOError, SystemCallError, ::SocketError => e
309
315
  raise Error::SocketError, "#{e.class}: #{e} (for #{self})"
310
316
  rescue OpenSSL::SSL::SSLError => e
311
317
  raise Error::SocketError, "#{e.class}: #{e} (for #{self})"
@@ -99,6 +99,7 @@ module Mongo
99
99
  d['upsert'] = true if doc[:upsert]
100
100
  d[Operation::COLLATION] = doc[:collation] if doc[:collation]
101
101
  d['hint'] = doc[:hint] if doc[:hint]
102
+ d['sort'] = doc[:sort] if doc[:sort]
102
103
  end
103
104
  }
104
105
 
@@ -130,6 +131,7 @@ module Mongo
130
131
  d[Operation::COLLATION] = doc[:collation] if doc[:collation]
131
132
  d[Operation::ARRAY_FILTERS] = doc[:array_filters] if doc[:array_filters]
132
133
  d['hint'] = doc[:hint] if doc[:hint]
134
+ d['sort'] = doc[:sort] if doc[:sort]
133
135
  end
134
136
  }
135
137
 
@@ -389,6 +389,11 @@ module Mongo
389
389
  # @option opts [ true, false ] :upsert Whether to upsert if the
390
390
  # document doesn't exist.
391
391
  # Can be :w => Integer, :fsync => Boolean, :j => Boolean.
392
+ # @option opts [ Hash ] :sort Specifies which document the operation
393
+ # replaces if the query matches multiple documents. The first document
394
+ # matched by the sort order will be replaced.
395
+ # This option is only supported by servers >= 8.0. Older servers will
396
+ # report an error for using this option.
392
397
  #
393
398
  # @return [ Result ] The response from the database.
394
399
  #
@@ -410,6 +415,7 @@ module Mongo
410
415
  Operation::U => replacement,
411
416
  hint: opts[:hint],
412
417
  collation: opts[:collation] || opts['collation'] || collation,
418
+ sort: opts[:sort] || opts['sort'],
413
419
  }.compact
414
420
  if opts[:upsert]
415
421
  update_doc['upsert'] = true
@@ -549,6 +555,11 @@ module Mongo
549
555
  # document doesn't exist.
550
556
  # @option opts [ Hash ] :write_concern The write concern options.
551
557
  # Can be :w => Integer, :fsync => Boolean, :j => Boolean.
558
+ # @option opts [ Hash ] :sort Specifies which document the operation
559
+ # updates if the query matches multiple documents. The first document
560
+ # matched by the sort order will be updated.
561
+ # This option is only supported by servers >= 8.0. Older servers will
562
+ # report an error for using this option.
552
563
  #
553
564
  # @return [ Result ] The response from the database.
554
565
  #
@@ -570,6 +581,7 @@ module Mongo
570
581
  Operation::U => spec,
571
582
  hint: opts[:hint],
572
583
  collation: opts[:collation] || opts['collation'] || collation,
584
+ sort: opts[:sort] || opts['sort'],
573
585
  }.compact
574
586
  if opts[:upsert]
575
587
  update_doc['upsert'] = true
@@ -1049,6 +1049,11 @@ module Mongo
1049
1049
  # May be specified as a Hash (e.g. { _id: 1 }) or a String (e.g. "_id_").
1050
1050
  # @option options [ Hash ] :let Mapping of variables to use in the command.
1051
1051
  # See the server documentation for details.
1052
+ # @option options [ Hash ] :sort Specifies which document the operation
1053
+ # replaces if the query matches multiple documents. The first document
1054
+ # matched by the sort order will be replaced.
1055
+ # This option is only supported by servers >= 8.0. Older servers will
1056
+ # report an error for using this option.
1052
1057
  #
1053
1058
  # @return [ Result ] The response from the database.
1054
1059
  #
@@ -1115,6 +1120,11 @@ module Mongo
1115
1120
  # May be specified as a Hash (e.g. { _id: 1 }) or a String (e.g. "_id_").
1116
1121
  # @option options [ Hash ] :let Mapping of variables to use in the command.
1117
1122
  # See the server documentation for details.
1123
+ # @option options [ Hash ] :sort Specifies which document the operation
1124
+ # updates if the query matches multiple documents. The first document
1125
+ # matched by the sort order will be updated.
1126
+ # This option is only supported by servers >= 8.0. Older servers will
1127
+ # report an error for using this option.
1118
1128
  #
1119
1129
  # @return [ Result ] The response from the database.
1120
1130
  #
data/lib/mongo/server.rb CHANGED
@@ -616,7 +616,9 @@ module Mongo
616
616
  return
617
617
  end
618
618
 
619
- if options[:generation] && options[:generation] < pool&.generation
619
+ # NOTE: You cannot use safe navigation here because if pool is nil you end
620
+ # up trying to evaluate Integer < nil which is invalid.
621
+ if options[:generation] && pool && options[:generation] < pool.generation
620
622
  return
621
623
  end
622
624
 
data/lib/mongo/socket.rb CHANGED
@@ -609,7 +609,7 @@ module Mongo
609
609
  yield
610
610
  rescue Errno::ETIMEDOUT => e
611
611
  raise Error::SocketTimeoutError, "#{e.class}: #{e} (for #{human_address})"
612
- rescue IOError, SystemCallError => e
612
+ rescue IOError, SystemCallError, ::SocketError => e
613
613
  raise Error::SocketError, "#{e.class}: #{e} (for #{human_address})"
614
614
  rescue OpenSSL::SSL::SSLError => e
615
615
  raise Error::SocketError, "#{e.class}: #{e} (for #{human_address})"
data/lib/mongo/version.rb CHANGED
@@ -5,5 +5,5 @@ module Mongo
5
5
  #
6
6
  # Note that this file is automatically updated via `rake candidate:create`.
7
7
  # Manual changes to this file will be overwritten by that rake task.
8
- VERSION = '2.21.3'
8
+ VERSION = '2.22.0'
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongo
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.21.3
4
+ version: 2.22.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - The MongoDB Ruby Team
@@ -553,7 +553,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
553
553
  - !ruby/object:Gem::Version
554
554
  version: '0'
555
555
  requirements: []
556
- rubygems_version: 3.7.1
556
+ rubygems_version: 3.7.2
557
557
  specification_version: 4
558
558
  summary: Ruby driver for MongoDB
559
559
  test_files: []