Skip to content

Instantly share code, notes, and snippets.

@sixty4bit
Created November 10, 2011 19:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sixty4bit/1355891 to your computer and use it in GitHub Desktop.
Save sixty4bit/1355891 to your computer and use it in GitHub Desktop.
Oracle can't handle more than 1000 values in an IN clause
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