Skip to content

ActiveRecord Hstore bug: can't update a key in the hash #6127

@joevandyk

Description

@joevandyk

joevandyk@f2318b2 shows a failing test.

  def test_updating_key                                                                             
    x = Hstore.create! :tags => { "key1" => "old value 1", "key2" => "old value 2" }                
    x.reload                                                                                        
    assert_equal "old value 1", x.tags["key1"]                                                      

    # Nothing gets saved/updated here.
    x.tags["key1"] = "new"                                                                          
    x.save!                                                                                         

    assert_equal "new", x.reload.tags["key1"]                                                       
    assert_equal "old value 2",   x.reload.tags["key2"]                                             
  end
  1) Failure:
test_updating_key(PostgresqlHstoreTest) [cases/adapters/postgresql/hstore_test.rb:55]:
Expected: "new"
  Actual: "old value 1"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions