Sha256: 7db2a328e6e1c6d4bd72c052fc6caa2c93d8805fb96e2bc976ae3f91476078fa

Contents?: true

Size: 525 Bytes

Versions: 1

Compression:

Stored size: 525 Bytes

Contents

# frozen_string_literal: true

module TableSaw
  module Formats
    class Copy < TableSaw::Formats::Base
      def header
        "COPY #{table_name} (#{quoted_columns}) FROM STDIN;"
      end

      def footer
        ['\.', "\n"]
      end

      def dump_row(row)
        row
      end

      private

      def quoted_columns
        TableSaw.schema_cache.columns_hash(table_name)
          .each_key
          .map { |name| TableSaw.connection.quote_column_name(name) }
          .join(', ')
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
table_saw-3.2.0 lib/table_saw/formats/copy.rb