Skip to content

Commit b7aee40

Browse files
Merge branch 'master' into set-resizable
2 parents 04985da + ca3e02e commit b7aee40

File tree

12 files changed

+34
-67
lines changed

12 files changed

+34
-67
lines changed

docs/reference/configuration.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,15 +396,15 @@ for details on driver options.
396396
driver_options:
397397
# When this flag is off, an aggregation done on a view will be executed over
398398
# the documents included in that view, instead of all documents in the
399-
# collection. When this flag is on, the view fiter is ignored.
399+
# collection. When this flag is on, the view filter is ignored.
400400
# broken_view_aggregate: true
401401

402402
# When this flag is set to false, the view options will be correctly
403403
# propagated to readable methods.
404404
# broken_view_options: true
405405

406406
# When this flag is set to true, the update and replace methods will
407-
# validate the paramters and raise an error if they are invalid.
407+
# validate the parameters and raise an error if they are invalid.
408408
# validate_update_replace: false
409409

410410

docs/reference/fields.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ Reading Uncastable Values
927927
`````````````````````````
928928

929929
When documents in the database contain values of different types than their
930-
represenations in Mongoid, if Mongoid cannot coerce them into the correct type,
930+
representations in Mongoid, if Mongoid cannot coerce them into the correct type,
931931
it will replace the value with ``nil``. Consider the following model and document in the
932932
database:
933933

@@ -1105,7 +1105,7 @@ used for MongoDB serialization and deserialization as follows:
11051105
end
11061106

11071107
The instance method ``mongoize`` takes an instance of your custom type object, and
1108-
converts it into a represenation of how it will be stored in the database, i.e. to pass
1108+
converts it into a representation of how it will be stored in the database, i.e. to pass
11091109
to the MongoDB Ruby driver. In our example above, we want to store our ``Point``
11101110
object as an ``Array`` in the form ``[ x, y ]``.
11111111

@@ -1228,7 +1228,7 @@ which extend its behavior at the your time model classes are loaded.
12281228

12291229
As an example, we will define a ``:max_length`` option which will add a length
12301230
validator for the field. First, declare the new field option in an initializer,
1231-
specifiying its handler function as a block:
1231+
specifying its handler function as a block:
12321232

12331233
.. code-block:: ruby
12341234

docs/reference/rails-integration.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ other Rails environment specific options by accessing config.mongoid. The
2424
``mongoid:config`` generator will create an initializer in
2525
``config/initializers/mongoid.rb`` which can also be used for configuring
2626
Mongoid. Note, though, that options set in your ``config/mongoid.yml`` will
27-
take precendence over options set elsewhere; it is recommended that whenever
27+
take precedence over options set elsewhere; it is recommended that whenever
2828
possible you use ``mongoid.yml`` as the default location for Mongoid
2929
configuration.
3030

docs/release-notes/mongoid-9.0.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,16 @@ prior has been dropped (you must use a minimum of version 8.0.)
154154
Deprecated functionality removed
155155
--------------------------------
156156

157+
**Breaking change:** The following deprecated functionality is now removed:
158+
157159
- The ``Mongoid::QueryCache`` module has been removed. Please replace any usages 1-for-1 with ``Mongo::QueryCache``.
158160
The method ``Mongoid::QueryCache#clear_cache`` should be replaced with ``Mongo::QueryCache#clear``.
159161
All other methods and submodules are identically named. Refer to the `driver query cache documentation
160162
<https://mongodb.com/docs/ruby-driver/current/reference/query-cache/>`_ for more details.
161163
- ``Object#blank_criteria?`` method is removed (was previously deprecated.)
164+
- ``Document#as_json :compact`` option is removed. Please call ```#compact`` on the
165+
returned ``Hash`` object instead.
166+
- The deprecated class ``Mongoid::Errors::InvalidStorageParent`` has been removed.
162167

163168

164169
``touch`` method now clears changed state

gemfiles/driver_master.gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# rubocop:todo all
22
source "https://rubygems.org"
33

4-
gem 'bson', git: "https://github.com/mongodb/bson-ruby", branch: '4-stable'
4+
gem 'bson', git: "https://github.com/mongodb/bson-ruby"
55
gem 'mongo', git: "https://github.com/mongodb/mongo-ruby-driver"
66

77
gem 'actionpack'

gemfiles/driver_stable.gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# rubocop:todo all
22
source "https://rubygems.org"
33

4-
gem 'mongo', git: "https://github.com/mongodb/mongo-ruby-driver", branch: '2.18-stable'
4+
gem 'mongo', git: "https://github.com/mongodb/mongo-ruby-driver", branch: '2.19-stable'
55

66
gem 'actionpack'
77

lib/mongoid/clients/sessions.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ def with_session(options = {})
5959
else
6060
raise ex
6161
end
62+
rescue *transactions_not_supported_exceptions
63+
raise Mongoid::Errors::TransactionsNotSupported
6264
ensure
6365
Threaded.clear_session(client: persistence_context.client)
6466
end
@@ -90,6 +92,8 @@ def transaction(options = {}, session_options: {})
9092
session.start_transaction(options)
9193
yield
9294
commit_transaction(session)
95+
rescue *transactions_not_supported_exceptions
96+
raise Mongoid::Errors::TransactionsNotSupported
9397
rescue Mongoid::Errors::Rollback
9498
abort_transaction(session)
9599
rescue Mongoid::Errors::InvalidSessionNesting
@@ -150,6 +154,22 @@ def after_rollback(*args, &block)
150154

151155
private
152156

157+
# Driver version 2.20 introduced a new exception for reporting that
158+
# transactions are not supported. Prior to that, the condition was
159+
# discovered by the rescue clause falling through to a different
160+
# exception.
161+
#
162+
# This method ensures that Mongoid continues to work with older driver
163+
# versions, by only returning the new exception.
164+
#
165+
# Once support is removed for all versions prior to 2.20.0, we can
166+
# replace this method.
167+
def transactions_not_supported_exceptions
168+
return nil unless defined? Mongo::Error::TransactionsNotSupported
169+
170+
Mongo::Error::TransactionsNotSupported
171+
end
172+
153173
# @return [ Mongo::Session ] Session for the current client.
154174
def _session
155175
Threaded.get_session(client: persistence_context.client)

lib/mongoid/document.rb

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -135,33 +135,6 @@ def as_document
135135
BSON::Document.new(as_attributes)
136136
end
137137

138-
# Calls #as_json on the document with additional, Mongoid-specific options.
139-
#
140-
# @note Rails 6 changes return value of as_json for non-primitive types
141-
# such as BSON::ObjectId. In Rails <= 5, as_json returned these as
142-
# instances of the class. In Rails 6, these are returned serialized to
143-
# primitive types (e.g. {'$oid'=>'5bcfc40bde340b37feda98e9'}).
144-
# See https://github.com/rails/rails/commit/2e5cb980a448e7f4ab00df6e9ad4c1cc456616aa
145-
# for more information.
146-
#
147-
# @example Get the document as json.
148-
# document.as_json(compact: true)
149-
#
150-
# @param [ Hash ] options The options.
151-
#
152-
# @option options [ true | false ] :compact (Deprecated) Whether to include fields
153-
# with nil values in the json document.
154-
#
155-
# @return [ Hash ] The document as json.
156-
def as_json(options = nil)
157-
rv = super
158-
if options && options[:compact]
159-
Mongoid::Warnings.warn_as_json_compact_deprecated
160-
rv = rv.compact
161-
end
162-
rv
163-
end
164-
165138
# Returns an instance of the specified class with the attributes,
166139
# errors, and embedded documents of the current document.
167140
#

lib/mongoid/warnings.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ def warning(id, message)
3030
end
3131

3232
warning :geo_haystack_deprecated, 'The geoHaystack type is deprecated.'
33-
warning :as_json_compact_deprecated, '#as_json :compact option is deprecated. Please call #compact on the returned Hash object instead.'
3433
warning :symbol_type_deprecated, 'The BSON Symbol type is deprecated by MongoDB. Please use String or StringifiedSymbol field types instead of the Symbol field type.'
3534
warning :legacy_readonly, 'The readonly! method will only mark the document readonly when the legacy_readonly feature flag is switched off.'
3635
warning :mutable_ids, 'Ignoring updates to immutable attribute `_id`. Please set Mongoid::Config.immutable_ids to true and update your code so that `_id` is never updated.'

spec/mongoid/criteria_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,6 @@
288288
Band.where(name: "Depeche Mode")
289289
end
290290

291-
292291
it "returns the criteria as a json hash" do
293292
expect(criteria.as_json).to eq([ band.serializable_hash.as_json ])
294293
end

0 commit comments

Comments
 (0)