Sha256: a13db32d3315942c1ff94d9746adee28e0a42cd7961f9c6be6eebe09446439b8

Contents?: true

Size: 560 Bytes

Versions: 3

Compression:

Stored size: 560 Bytes

Contents

module Populator
  module Adapters
    module Postgresql
      def populate(table, columns, rows, name = nil)
        queries = []
        rows.each do |row|
          row.gsub!(/^\(\d{1,}/, "(DEFAULT")
          queries << "INSERT INTO #{table} #{columns} VALUES #{row}"
        end
        execute(queries.join("; "), name)
      end
    end
  end
end

module ActiveRecord # :nodoc: all
  module ConnectionAdapters
    class PostgreSQLAdapter < ActiveRecord::ConnectionAdapters::AbstractAdapter
      include Populator::Adapters::Postgresql
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
populator3-0.2.7 lib/populator/adapters/postgresql.rb
populator3-0.2.6 lib/populator/adapters/postgresql.rb
populator3-0.2.4 lib/populator/adapters/postgresql.rb