Sha256: be2db13aa24a8ab5da4cac68eaeda757d43fd9c75a70a550ef76d86fbd9e9f76

Contents?: true

Size: 534 Bytes

Versions: 1

Compression:

Stored size: 534 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.adapter.quote_column_name(name) }
          .join(', ')
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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