Sha256: 46d00876f2869ad9726924b732daf3fdd8cf4f967d41f8fe507e14b740d5cf81

Contents?: true

Size: 1001 Bytes

Versions: 12

Compression:

Stored size: 1001 Bytes

Contents

#!/usr/bin/env ruby
################################################################################
# To run this "app", do a "rake setup" first.
# To work with this app, run the "rake console" task, which loads this file.
################################################################################
require 'rubygems'
require 'bundler/setup'
require 'pg'
require 'active_record'
require 'postgresql_cursor'

ActiveRecord::Base.establish_connection( adapter: 'postgresql',
  database: ENV['TEST_DATABASE'] || 'postgresql_cursor_test',
  username: ENV['TEST_USER']     || ENV['USER'] || 'postgresql_cursor')

class Product < ActiveRecord::Base
  def self.generate(max=1_000)
    Product.destroy_all
    max.times do |i|
      connection.execute("insert into products values (#{i})")
    end
  end

  def tests
    Product.where("id>0").each_row(block_size:100) { |r| p r["id"] } # Hash
    Product.where("id>0").each_instance(block_size:100) { |r| p r.id } # Instance
  end
end

#Product.generate

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
postgresql_cursor-0.6.9 test-app/app.rb
postgresql_cursor-0.6.8 test-app/app.rb
postgresql_cursor-0.6.7 test-app/app.rb
postgresql_cursor-0.6.6 test-app/app.rb
postgresql_cursor-0.6.5 test-app/app.rb
postgresql_cursor-0.6.4 test-app/app.rb
postgresql_cursor-0.6.3 test-app/app.rb
postgresql_cursor-0.6.2 test-app/app.rb
postgresql_cursor-0.6.1 test-app/app.rb
postgresql_cursor-0.6.0 test-app/app.rb
postgresql_cursor-0.5.1 test-app/app.rb
postgresql_cursor-0.5.0 test-app/app.rb