Repository navigation
Conversation
…pper bound to < 8.2 Co-authored-by: Cursor <cursoragent@cursor.com>
… 8.0.0 Co-authored-by: Cursor <cursoragent@cursor.com>
…redefine 4-arg signature Widening the activesupport/activemodel upper bound to < 8.2 allows Bundler to resolve activesupport versions (8.0.3+, 8.1.x) whose ActiveSupport::ClassAttribute.redefine signature gained a required namespaced_name parameter (owner, name, namespaced_name, value), replacing the old (owner, name, value) signature. Mongoid's custom discriminator_key= override called redefine directly with the old 3-arg signature, raising ArgumentError: wrong number of arguments (given 3, expected 4) whenever a newer activesupport was loaded. Detect the installed redefine arity and call it with the namespaced_name Rails' own class_attribute macro uses (__class_attr_discriminator_key) when the new signature is present, falling back to the old signature otherwise.
The previous fix addressed the ArgumentError from ActiveSupport::ClassAttribute.redefine's new 4-arg signature in Rails 8.1, but didn't actually fix discriminator_key propagation. class_attribute :discriminator_key defines a reader backed by a private __class_attr_discriminator_key attribute, but that reader is immediately overwritten by 'delegate :discriminator_key, to: ::Mongoid' right after, in the same included block. So updating the private attribute via ActiveSupport::ClassAttribute.redefine's new signature had no effect on the actual (delegate-based) reader in use. Prior to Rails 8.1, ActiveSupport::ClassAttribute.redefine(owner, name, value) worked differently: it redefined the public reader method directly on owner's singleton class, which happened to bypass this issue entirely. Mimic that directly and simply, independent of ActiveSupport::ClassAttribute's internal storage mechanism, so it works consistently across versions and subclasses still inherit the value through normal Ruby method lookup. Co-authored-by: Cursor <cursoragent@cursor.com>
|
It would be nice if we can drop the mongoid fork, and I think it's possible. Two of our four commits (the touch and created_at fixes) are already in the latest release, 9.1.1. The other two change child validation. Upstream added that fix and then reverted it for performance reasons, so if we still need it we can override it in an initializer instead of keeping a fork. Here are the gems we should bump on your rails upgrade PR
|
Author
|
Superseded by #2 (Mongoid 8.1.13 with the same activemodel < 8.2 widening; supply_chain moves to it in getaroom/supply_chain#5175). Branch |
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.
No description provided.