Skip to content
This repository has been archived by the owner on Sep 21, 2020. It is now read-only.

Commit

Permalink
Merge pull request #33 from newspaperclub/master
Browse files Browse the repository at this point in the history
Correctly parse double quoted hstore format on multiple lines
  • Loading branch information
diogob committed Sep 14, 2012
2 parents c1291ac + 1ee3f4b commit 053ea4c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/activerecord-postgres-hstore/string.rb
Expand Up @@ -24,7 +24,7 @@ def from_hstore
[k,v].map { |t|
case t
when nil then t
when /^"(.*)"$/ then $1.gsub(/\\(.)/, '\1')
when /\A"(.*)"\Z/m then $1.gsub(/\\(.)/, '\1')
else t.gsub(/\\(.)/, '\1')
end
}
Expand Down
6 changes: 6 additions & 0 deletions spec/activerecord-postgres-hstore_spec.rb
Expand Up @@ -78,5 +78,11 @@
''.from_hstore.should eq({})
' '.from_hstore.should eq({})
end

it "should not change values with line breaks" do
input = { "a" => "foo\n\nbar" }
output = input.to_hstore
output.from_hstore.should eq(input)
end

end

0 comments on commit 053ea4c

Please sign in to comment.