Module: MultiTenant::CopyFromClient
- Defined in:
- lib/activerecord-multi-tenant/copy_from_client.rb
Instance Method Summary collapse
Instance Method Details
#copy_from_client(columns, &block) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/activerecord-multi-tenant/copy_from_client.rb', line 22 def copy_from_client(columns, &block) conn = connection.raw_connection column_types = columns.map { |c| type_for_attribute(c.to_s) } helper = MultiTenant::CopyFromClientHelper.new(conn, column_types) conn.copy_data %{COPY #{quoted_table_name}("#{columns.join('","')}") FROM STDIN}, PG::TextEncoder::CopyRow.new do block.call helper end helper.count end |