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

Remove need for include Mongoid::Attributes::Dynamic #1546

Open
wants to merge 66 commits into
base: main
Choose a base branch
from

Conversation

sahglie
Copy link
Contributor

@sahglie sahglie commented Aug 26, 2023

doc.unset(field) in mongoid >= 7.x interprets this as setting an attribute and since there is no attribute called "#{key}.#{digest}" it fails. Previous version of mongoid appear to just update the hash that #{key} pointed to. So, looks like we just need to remove the cached digest from the hash using a different method. This would do it:

if (doc[k].try(:[], digest).try(:[], :count)).to_i > 1
  doc.inc("#{field}.count" => -1)
else
  h = doc[k] || {}
  h.delete(digest)
  doc.set("#{k}": h)
end

With this update and removing include Mongoid::Attributes::Dynamic from Problem class the entire test suite passes.

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.

None yet

2 participants