Skip to content

Commit

Permalink
Update handling nil value for PgHash
Browse files Browse the repository at this point in the history
  • Loading branch information
unavailabl3 authored and shioyama committed Jan 6, 2025
1 parent 30994db commit 5837213
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/mobility/backends/active_record/pg_hash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def read(locale, _options = nil)
def write(locale, value, _options = nil)
if value.nil?
translations.delete(locale.to_s)
nil
else
translations[locale.to_s] = value
end
Expand Down
2 changes: 2 additions & 0 deletions spec/integration/active_record_compatibility_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
post.send(backend_for(post, :title).association_name).first.value = "association changed value"
post.save
expect(Post.first.title).to eq("association changed value")
post.title = nil
expect(post.title).to eq(nil)
end

it "resets cache when model is reloaded" do
Expand Down

0 comments on commit 5837213

Please sign in to comment.