Release candidate for 9.1.0#6145
Open
jamis wants to merge 1 commit intomongodb:masterfrom
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Bumps Mongoid’s declared version to 9.1.0 for the 9.1.0 release candidate, aligning the repository’s version metadata and the runtime Mongoid::VERSION constant.
Changes:
- Update
product.ymlversion number to 9.1.0. - Update
Mongoid::VERSIONto 9.1.0.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| product.yml | Updates release metadata version number to 9.1.0. |
| lib/mongoid/version.rb | Updates the gem’s runtime version constant to 9.1.0. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The MongoDB Ruby team is pleased to announce version 9.1.0 of the
mongoidgem - an Ruby ODM for MongoDB. This is a new minor release in the 9.x series of Mongoid.Install this release using RubyGems via the command line as follows:
Or simply add it to your
Gemfile:Have any feedback? Click on through to MongoDB's JIRA and open a new ticket to let us know what's on your mind 🧠.
New Features
MONGOID-5411 allow results to be returned as demongoized hashes (PR)
Mongoid now supports a new
rawdirective when building queries. When present, the resulting query will be returned as hashes, rather than instantiated document models. The hashes will not be "demongoized" -- the values will be returned exactly as provided by the database, directly.If you specify
typed: true, the hashes will be returned with the values translated from the raw value stored in the database, into the corresponding type defined by thefielddefinitions on the model. (That is to say, they will be "demongoized".)For example:
The
typed: trueoption will also honor embedded documents, correctly demongoizing the embedded hashes according to their declared types.MONGOID-5752 Add Mongoid::Criteria#to_mql (PR)
To help with inspecting the queries that Mongoid generates, you can now call
#to_mqlon Criteria instances.MONGOID-5827 Allow duplicate indexes to be declared (PR)
Mongoid will ignore indexes that differ only in the options used to declare them. This includes index names! This behavior will change in the future, but to ease the transition, you can set
Mongoid.allow_duplicate_index_declarations = trueto allow these near-identical indexes to be declared and processed by the server.MONGOID-5882 Isolation state (PR)
Some applications will use threads for concurrency. Others will use fibers. Prior to this PR, Mongoid worked fine with threads, but it's internal state could get into odd states when run under fibers.
This PR allows applications to indicate which isolation level they wish to use, and Mongoid's state will be isolated to that scope.
When using the
:fiberisolation level, Mongoid's internal state will be inherited from any parent fiber. If you want to make sure a fiber begins with a clean slate, you can wipe the isolation state withMongoid::Threaded.reset!.MONGOID-5892 - Treat serialize option only with values of nil and [] differently (PR)
Previously, passing
only: []toserializable_hashwas treated the same as passingonly: nil, meaning all fields were included. The correct behavior is to treat an empty array as "include no fields," suppressing all output.This fix is gated behind the
Mongoid.serializable_hash_with_legacy_onlyfeature flag. In 9.1 and later, the flag defaults totrue(legacy behavior); set it tofalseto opt into the new behavior. The default will flip tofalsein Mongoid 10.0, and the flag will be removed in 11.0.MONGOID-5910 Implement enumerable methods on top level models (any?, many?, and one?) (PR)
You may now invoke the enumerable methods
#any?,#many?, and#one?onCriteriainstances. Invoking them at the class level will delegate to those methods, as well.MONGOID-5731 Add Criteria#eager_load method to use aggregation pipeline for eager loading (PR)
A new
Criteriamethod,#eager_load, has been added. It is effectively the same as using#includes(joining associations into a single result), but it uses an aggregation pipeline under the covers to issue a single query, instead of the multiple queries that#includesmay emit. The#eager_loadmethod will typically perform better onhas_manyandhas_and_belongs_to_manyassociations, and on queries where you are joining on multiplebelongs_toorhas_oneassociations.If you use
#eager_loadto attempt to join on an embedded association (embeds_one,embeds_many), it will silently fall back to using#includes.MONGOID-5930 Add Mongoid::Config.allow_reparenting_via_nested_attributes (PR)
Add
Mongoid::Config.allow_reparenting_via_nested_attributes, defaulting tofalse. When false, this prevents dependent has_many records from being reparented via use of nested attributes. When true, records may be reparented via nested attributes.This setting will be removed in Mongoid 10, and reparenting via nested attributes will not be allowed.
MONGOID-5898 Add vector search support (PR)
Mongoid can now define vector search indexes, and provides a helper interface for querying documents by their semantic meaning using those indexed vector fields.
The simplest interface will define an
Arrayfield, and a corresponding vector search index:For more sophisticated configurations, you may also declare the field and the index separately:
Then, create the new search indexes:
Once the indexes are created, you can query them using the
vector_searchmethod:MONGOID-5923 Support auto emdedding vector search indexes and searches (PR)
Mongoid can now define vector search indexes with auto-embedding, and provides a helper interface for querying documents by their semantic meaning using those indexed vector fields.
The simplest interface will define a
Stringfield using thevoyage-4model.You may declare the model and other parameters as well, if desired:
Then, create the new search indexes:
Once the indexes are created, you can query them using the
auto_embed_searchmethod:MONGOID-5750 Allow build_foo on embeds_one/has_one/etc. to specify the associated document's type (PR)
When using
build_<association>on anembeds_one/has_one/belongs_to(etc.) association, you can now specify the type of the associated document. For example:The same syntax works with
create_<association>.MONGOID-5030 Short-circuit trivial queries where
$inis given an empty array (PR)When
Mongoid.allow_short_circuit_queries == true, any top-level$inquery condition that evaluates to an empty array will cause the query to be short-circuited, returning an empty array without sending the query to the database.The
Mongoid.allow_short_circuit_queriessetting defaults tofalse.Other New Features
Bug Fixes
MONGOID-5867 Merge touch updates into embedded document insert (PR)
When inserting an embedded document with a touchable parent (the default for
embedded_in), Mongoid issues two separateupdate_onecalls:$push— inserts the embedded document (insert_as_embedded)$set— updatesupdated_aton the parent chain (after_savetouch callback)This commit merges both into a single
update_one, eliminating the redundant round-trip.insert_as_embeddedgathers touch updates via_gather_touch_updatesand merges the$setinto the same operation as the$pushafter_savetouch callback checks aThreadedflag and skips the now-redundant persistence, while still running:touchcallbacks and cleaning up dirty trackingThreadedflag follows the existingbegin_autosave/exit_autosave/autosaved?patternMONGOID-5751 avoid unnecessary autosaves of unchanged subtrees (PR)
The legacy behavior of associations with
autosave: trueresulted in all#savebeing invoked on all children of those associations, whether those children actually needed it or not. All correspondingafter_savehooks were invoked as well, recursively, clear to the bottom of the autosave tree.This PR changes this behavior, ensuring that subtrees are only autosaved if there are any changed documents in the subtree. As there may be users that depend on the legacy behavior (expecting
after_savehooks to be invoked even if the record has not changed, for instance), a feature flag has been added to allow the legacy behavior to be opted into.When
true, the legacy behavior prevails. If your program depends on this legacy behavior, you are encouraged to rewrite the affected code, because this flag will go away in Mongoid 10, and the legacy autosave behavior will be removed.Other Bug Fixes