multilang-hstore
multilang-hstore copied to clipboard
Can't assign nil to a multilang field
I've noticed some my rspec tests failed because new instance had empty string "" instead of nil:
class CustomField < ActiveRecord::Base
multilang :name
...
end
c = CustomField.new
=> #<CustomField...
c.name
=> ""
c.name = {}
=> {}
c.name
=> ""
c.name = {I18n.locale => nil}
=> {:ru=>nil}
c.name
=> ""
What is the reason of such behavior? PostgreSQL seems to work with NULL values in hstore: http://www.postgresql.org/docs/9.0/static/hstore.html
Hi,
this is legacy behavior from the initial gem.
It makes sense, it should be nullable. Can you come up with a pull request?
This would be the goal:
- Modify logic so it allows nulls
- Update Reame
I'll make a major bump version adding instructions in the readme warning of this breaking change.