-
Notifications
You must be signed in to change notification settings - Fork 87
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
Backend container reader mixes up dirty tracking and creates empty locale hash #540
Comments
I think one culprit is this: mobility/lib/mobility/backends/active_record/container.rb Lines 109 to 111 in 14d2ab9
Another one might be here: mobility/lib/mobility/backends/active_record/container.rb Lines 113 to 118 in 14d2ab9
Maybe something like this could fix it? --- a/lib/mobility/backends/active_record/container.rb
+++ b/lib/mobility/backends/active_record/container.rb
@@ -107,14 +107,15 @@ Implements the {Mobility::Backends::Container} backend for ActiveRecord models.
private
def model_translations(locale)
- model[column_name][locale] ||= {}
+ model[column_name][locale] || {}
end
def set_attribute_translation(locale, value)
translations = model[column_name] || {}
translations[locale.to_s] ||= {}
translations[locale.to_s][attribute] = value
- model[column_name] = translations
+ translations[locale.to_s].compact!
+ model[column_name] = translations.compact
end
class Coder |
Thanks! You're right we should do the same thing on all AR backends that use
maybe the changes you made above would help make that possible, I haven't looked at the code for quite a while. |
I played a little bit with it and could fix the errors I reported but some existing specs were failing whenever I touched something. Looks like a deeper investigation is needed here, I'll see if I can find some time the next days. |
Thanks! 🙇♂️ |
fixes dirty tracking and creating empty translation hashes on read fixes shioyama#540
I gave it a try in #543! specs should pass and issues are fixed. Lets discuss the code there. |
fixes dirty tracking and creating empty translation hashes on read fixes shioyama#540
fixes dirty tracking and creating empty translation hashes on read fixes shioyama#540
fixes dirty tracking and creating empty translation hashes on read fixes #540
fixes dirty tracking and creating empty translation hashes on read fixes shioyama#540
This is in a similar vein to #535: The container backend does some weird things to the dirty tracking after a reload or after accessing a reader.
One is about
.changes
where it states that the column changed like this:{"translations"=>[{}, {}]}
simply after reload.Second one is that when a reader is accessed it adds the locale key to the translations, but with empty hash:
Bug template
The text was updated successfully, but these errors were encountered: