提交 135b3a0d 编写于 作者: A Aaron Patterson

multiple key / values work

上级 776af48a
......@@ -51,7 +51,10 @@ def string_to_time(string)
end
def cast_hstore(string)
Hash[[string.split('=>').map { |k| k[1...-1] }]]
kvs = string.split(', ').map { |kv|
kv.split('=>').map { |k| k[1...-1] }
}
Hash[kvs]
end
end
# :startdoc:
......
......@@ -37,4 +37,10 @@ def test_select
x = Hstore.find :first
assert_equal({'1' => '2'}, x.tags)
end
def test_select_multikey
@connection.execute "insert into hstores (tags) VALUES ('1=>2,2=>3')"
x = Hstore.find :first
assert_equal({'1' => '2', '2' => '3'}, x.tags)
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册