MONGOID-5665 [Monkey Patch Removal] Remove Object#__find_args__#5706
Merged
jamis merged 6 commits intomongodb:masterfrom Nov 6, 2023
Merged
MONGOID-5665 [Monkey Patch Removal] Remove Object#__find_args__#5706jamis merged 6 commits intomongodb:masterfrom
jamis merged 6 commits intomongodb:masterfrom
Conversation
…e where it is now a private method.
2 points to note:
- __find_args__ was mistakenly called in Atomic#unset method. Although technically __find_args__ does a similar thing as what #unset requires for its argument preparation, this is pure coincidence and its a kludge to use find_args here. So I've inlined the code and made a new private method.
- __find_args__ for Range previously called to_a. This is actually a bug / DOS risk, because ranges of strings tend to explode when you use to_a. As an example, ('64e0'..'64ff').to_a.size => 9320, and it gets much worse for 24-char BSON ids! Interestingly however, MongoDB itself can handle ranges of ids gracefully, so I am now just passing them into the DB as-is and it magically works--I've added tests.
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.
Fixes MONGOID-5665
Object#__find_args__is a kernel monkey patch intended for use inCriteria::Findable. It prepare arguments for theCriteria.findmethod (it's somewhat beguiling name is intended to mean "args for the find method".)Please merge #5702 before this one.
This PR does the following:
Object#__find_args__to a private method inCriteria::Findable(now named#prepare_ids_for_find)__find_args__was mistakenly called inAtomic#unsetmethod. Although__find_args__does a similar thing as what#unsetrequires, it is pure coincidence and its usage here is a kludge. So I've inlined the code and made a new private method.__find_args__for Range previously called to_a. In the case of String, this is actually a bug / DOS risk, because ranges of strings tend to explode when you use to_a. As an example,('64e0'..'64ff').to_a.size => 9320, and it gets exponentially worse for 24-char BSON ids! Interestingly however, the MongoDB server itself can handle ranges of id strings gracefully, so I am now just passing them into the DB as-is and it magically works--I've added tests. (Range<Numeric, Numeric> is still converted to_a)Setof IDs as an arg.Overall progress is tracked here: http://tinyurl.com/mongoid-monkey. Refer to MONGOID-5660 for context.