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

checks added for :update_attribute for dynamic attributes refs #3875 #3882

Closed
wants to merge 1 commit into from

Conversation

Shwetakale
Copy link
Contributor

When we call process_attribute, it does all the checks for ensuring that
dynamic attributes are allowed.

Note This impacts the :counter_cache option as it requires dynamic fields.
When using the counter_cache, the model must include
Mongoid::Attributes::Dynamic

refs #3875

When we call process_attribute, it does all the checks for ensuring that
dynamic attributes are allowed.

This impacts the :counter_cache option as it requires dynamic fields.
When using the counter_cache, the model must include
Mongoid::Attributes::Dynamic
@arthurnn
Copy link
Contributor

changing the behaviour of the counter_cache to make it add a include Mongoid::Attributes::Dynamic is probably not a good idea.

@gautamrege
Copy link

@arthurnn Considering that :counter_cache does imply adding Dynamic fields, I believe we should either include this module or explicitly added field <model>_count, type: Integer in the model.

@arthurnn
Copy link
Contributor

@gautamrege thats right +1 , I will double check the documentation for counter_cache and see if we state this in there, before merging this.
thanks

@Shwetakale
Copy link
Contributor Author

@durran Any feedback on this PR? This bug can still reproduced against master.

@estolfo
Copy link
Contributor

estolfo commented Dec 21, 2015

@Shwetakale we still need to figure out how to allow counter_cache to continue to work with this change. Including Mongoid::Attributes::Dynamic is not a good idea as it'll have unexpected behavior.

@Shwetakale
Copy link
Contributor Author

@estolfo As per this, In case of counter cache field needs to be manually added in parent document and here as field is not added in parent_document I have added Mongoid::Attributes::Dynamic so should we add field in parent document instead of Mongoid::Attributes::Dynamic ?

@estolfo
Copy link
Contributor

estolfo commented Dec 21, 2015

Yes, we should add the attribute on the parent document and not rely on Mongoid::Attributes::Dynamic

@Shwetakale
Copy link
Contributor Author

@estolfo Ok I will update PR.

@estolfo
Copy link
Contributor

estolfo commented Dec 21, 2015

thanks!

Shwetakale added a commit to joshsoftware/mongoid that referenced this pull request Dec 21, 2015
…ongodb#3882

When we call process_attribute, it does all the checks for ensuring that
dynamic attributes are allowed.

Note This impacts the :counter_cache option as it requires field
defined on
parent.
@Shwetakale
Copy link
Contributor Author

@estolfo Closing this PR as created new one with updated code from mongoid master branch.

@Shwetakale Shwetakale closed this Dec 21, 2015
Shwetakale added a commit to joshsoftware/mongoid that referenced this pull request Sep 15, 2016
Shwetakale added a commit to joshsoftware/mongoid that referenced this pull request Sep 17, 2016
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.

4 participants