Sha256: 373f1464fd8848c2dce7e655548dadede6915475d56fc3b39d33140a60aab936
Contents?: true
Size: 1.51 KB
Versions: 2
Compression:
Stored size: 1.51 KB
Contents
require 'spec_helper' describe Upsert do describe 'hstore on pg' do it "just works" do require 'pg_hstore' Pet.connection.execute 'CREATE EXTENSION HSTORE' Pet.connection.execute "ALTER TABLE pets ADD COLUMN crazy HSTORE" upsert = Upsert.new $conn, :pets upsert.row({name: 'Bill'}, crazy: nil) row = Pet.connection.select_one(%{SELECT crazy FROM pets WHERE name = 'Bill'}) row['crazy'].should == nil upsert.row({name: 'Bill'}, crazy: {a: 1}) row = Pet.connection.select_one(%{SELECT crazy FROM pets WHERE name = 'Bill'}) crazy = PgHstore.parse row['crazy'] crazy.should == { a: '1' } upsert.row({name: 'Bill'}, crazy: nil) row = Pet.connection.select_one(%{SELECT crazy FROM pets WHERE name = 'Bill'}) row['crazy'].should == nil upsert.row({name: 'Bill'}, crazy: {a: 1}) row = Pet.connection.select_one(%{SELECT crazy FROM pets WHERE name = 'Bill'}) crazy = PgHstore.parse row['crazy'] crazy.should == { a: '1' } upsert.row({name: 'Bill'}, crazy: {whatdat: 'whodat'}) row = Pet.connection.select_one(%{SELECT crazy FROM pets WHERE name = 'Bill'}) crazy = PgHstore.parse row['crazy'] crazy.should == { a: '1', whatdat: 'whodat' } 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' } end end end if ENV['DB'] == 'postgresql'
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
upsert-1.1.5 | spec/hstore_spec.rb |
upsert-1.1.4 | spec/hstore_spec.rb |