Skip to content

Commit

Permalink
Trying to get it to work with postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
workmaster2n committed Oct 9, 2013
1 parent 6a9b4a8 commit 1d5eae3
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ gem 'rake'
gem 'rspec', '~>2'
gem 'activerecord'
gem 'mysql2'
gem 'pg'
6 changes: 6 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@ GEM
tzinfo (~> 0.3.37)
arel (4.0.0)
atomic (1.1.14)
atomic (1.1.14-java)
builder (3.1.4)
bump (0.3.5)
diff-lcs (1.1.3)
i18n (0.6.5)
minitest (4.7.5)
multi_json (1.8.0)
mysql2 (0.3.13)
pg (0.17.0)
pg (0.17.0-x86-mingw32)
rake (10.0.2)
rspec (2.12.0)
rspec-core (~> 2.12.0)
Expand All @@ -41,6 +44,8 @@ GEM
rspec-mocks (2.12.0)
thread_safe (0.1.3)
atomic
thread_safe (0.1.3-java)
atomic
tzinfo (0.3.37)

PLATFORMS
Expand All @@ -53,5 +58,6 @@ DEPENDENCIES
bump
mysql2
parallel!
pg
rake
rspec (~> 2)
52 changes: 52 additions & 0 deletions spec/cases/map_with_ar_postges.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
require File.expand_path('spec/spec_helper')
require "active_record"

Tempfile.open("yyy") do |f|
database = "parallel_with_ar_test"

ActiveRecord::Schema.verbose = false
ActiveRecord::Base.establish_connection(
:adapter => 'postgresql',
:database => database,
:username => 'tyler',
:pool => 5,
:port => 5432,
:reconnect => true
)

class User < ActiveRecord::Base
end

unless User.table_exists?
ActiveRecord::Schema.define(:version => 1) do
create_table :users do |t|
t.string :name
end
end
end



User.delete_all

User.create!(:name => "X")

Parallel.map(1..8) do |i|
puts "making user"
ActiveRecord::Base.connection.reconnect!
User.create!(:name => i)
end


puts "User.count: #{User.count}"

puts User.connection.reconnect!.inspect

Parallel.map(1..8, :in_threads => 4) do |i|
User.create!(:name => i)
end

User.create!(:name => "X")

puts User.all.map(&:name).sort.join("-")
end

0 comments on commit 1d5eae3

Please sign in to comment.