Sha256: d809e5b55a8f423771b180bb557de5ef013dd43f832261c2aeb98eb3bdfa0251

Contents?: true

Size: 561 Bytes

Versions: 1

Compression:

Stored size: 561 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

1 entries across 1 versions & 1 rubygems

Version Path
populator-1.0.0 lib/populator/adapters/postgresql.rb