Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MONGOID-5677 [Monkey Patch Removal] Remove Hash#to_criteria and Criteria#to_criteria. Add Criteria.from_hash #5717

Merged
merged 3 commits into from
Nov 8, 2023

Conversation

johnnyshields
Copy link
Contributor

@johnnyshields johnnyshields commented Sep 4, 2023

Fixes MONGOID-5677

Hash#to_criteria is a kernel Monkey patch that converts a Hash to a Criteria by currying its key-values to an initialized Criteria class. It looks like it was done in order to support passing in a hash as an arg to Criteria.merge!, there's not a major use for it otherwise (Criteria also doesn't define #to_h)

This PR does the following:

  • Remove Hash#to_criteria
  • Remove Criteria#to_criteria, which just returns self.
  • Add Criteria.from_hash and add specs for it (there were no specs for Hash#to_criteria) It's debatable whether we should even add this, but someone might be using Hash#to_criteria so oh well...
  • Add specs to Criteria.merge! in the case that a Hash is given as an argument.

In addition to this PR, I will raise a deprecation PR for Mongoid 8.2 that provides a stable upgrade path.

Overall progress is tracked here: http://tinyurl.com/mongoid-monkey. Refer to MONGOID-5660 for context.

@johnnyshields johnnyshields changed the title [Monkey Patch Removal] Remove Hash#to_criteria and Criteria#to_criteria. Add Criteria.from_hash MONGOID-5677 [Monkey Patch Removal] Remove Hash#to_criteria and Criteria#to_criteria. Add Criteria.from_hash Sep 4, 2023
@jamis jamis merged commit 0aaf8d5 into mongodb:master Nov 8, 2023
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants