Repository navigation
Conversation
|
We need to get CI back going in this project, care to migrate Travis CI into GHA first in a separate PR? |
|
Thank you @leamotta for identifying the Mongoid 8.1 storage-options change. The public Posted by an AI on behalf of @dblock. |
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.
Summary
Mongoid 8.1 changed
storage_optionsfrom acattr_accessor(real@@class variable) to aclass_attribute(backed by singleton methods). The#documentsmethod writes the dynamic snapshot class's storage withklass.class_variable_set :@@storage_options, ..., which silently no-ops under 8.1. The variable gets set but Mongoid never reads it. The snapshot class falls back to default storage options and queries blow up with[73:InvalidNamespace].Fix
Replace the
class_variable_setcall with the publicstore_inAPI, which routes through Mongoid's official writer and works under bothcattr_accessor(≤ 8.0) andclass_attribute(≥ 8.1):store_in(client:, collection:)has been the stable public API since Mongoid 3.0, so this is backwards-compatible with Mongoid 6, 7, 8.0, and 8.1.Repro
Under Mongoid 8.1, any query against a snapshot collection (e.g.
MyIndex.latest_or_new.documents("output").where(...)) raisesMongo::Error::OperationFailure: [73:InvalidNamespace].References
storage_options.rb:cattr_accessor :storage_optionsstorage_options.rb:class_attribute :storage_options