Skip to content

Commit

Permalink
new pg-hstore with real support for bind variables
Browse files Browse the repository at this point in the history
  • Loading branch information
seamusabshere committed Dec 20, 2012
1 parent 94b6e31 commit 364eda2
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
1.1.6 / 2012-12-20

* Bug fixes

* Require pg-hstore >=1.1.1 which doesn't escape single quotes and backslashes when output is going to be used in a bind variable (as it is here)

1.1.5 / 2012-12-10

* Bug fixes
Expand Down
2 changes: 1 addition & 1 deletion lib/upsert/connection/postgresql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def bind_value(v)
case v
when Hash
# you must require 'pg_hstore' from the 'pg-hstore' gem yourself
::PgHstore.dump(v)[1...-1]
::PgHstore.dump v, true
else
super
end
Expand Down
2 changes: 1 addition & 1 deletion lib/upsert/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
class Upsert
VERSION = "1.1.5"
VERSION = "1.1.6"
end
7 changes: 6 additions & 1 deletion spec/hstore_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,15 @@
crazy = PgHstore.parse row['crazy']
crazy.should == { a: '1', whatdat: 'whodat' }

upsert.row({name: 'Bill'}, crazy: {whatdat: "D'ONOFRIO"})
row = Pet.connection.select_one(%{SELECT crazy FROM pets WHERE name = 'Bill'})
crazy = PgHstore.parse row['crazy']
crazy.should == { a: '1', whatdat: "D'ONOFRIO" }

upsert.row({name: 'Bill'}, crazy: {a: 2})
row = Pet.connection.select_one(%{SELECT crazy FROM pets WHERE name = 'Bill'})
crazy = PgHstore.parse row['crazy']
crazy.should == { a: '2', whatdat: 'whodat' }
crazy.should == { a: '2', whatdat: "D'ONOFRIO" }
end
end
end if ENV['DB'] == 'postgresql'
2 changes: 1 addition & 1 deletion upsert.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Gem::Specification.new do |gem|
gem.add_development_dependency 'yard'
gem.add_development_dependency 'activerecord-import'
gem.add_development_dependency 'pry'
gem.add_development_dependency 'pg-hstore', ">=1.1.0"
gem.add_development_dependency 'pg-hstore', ">=1.1.2"

unless RUBY_VERSION >= '1.9'
gem.add_development_dependency 'orderedhash'
Expand Down

0 comments on commit 364eda2

Please sign in to comment.