Created
November 10, 2011 19:30
-
-
Save sixty4bit/1355891 to your computer and use it in GitHub Desktop.
Oracle can't handle more than 1000 values in an IN clause
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
gem 'activerecord', '3.0.4' | |
gem 'activerecord-oracle_enhanced-adapter', '1.4.0' | |
require 'active_record' | |
ActiveRecord::Base.establish_connection( :adapter => 'oracle_enhanced', :database => 'orcl', | |
:username => 'hr', :password => 'hr') | |
ActiveRecord::Base.connection.instance_eval do | |
drop_table :jobs rescue nil | |
drop_table :job_events rescue nil | |
create_table :jobs, :force => true do |t| | |
t.string :name | |
end | |
create_table :job_events, :force => true do |t| | |
t.integer :job_id | |
t.string :status | |
end | |
end | |
class Job < ActiveRecord::Base | |
has_many :job_events | |
end | |
class JobEvent < ActiveRecord::Base | |
belongs_to :job | |
end | |
ActiveRecord::Base.transaction do | |
1001.times do |i| | |
j = Job.create :name => "Job #{i}" | |
JobEvent.create :job => j, :status => "finished" | |
end | |
end | |
JobEvent.where(:status => 'finished').includes(:job).all |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment