Sha256: 769d1aacd08a308d46c481ab9d3573cb1607e1323e96e159d787c87e593e1911

Contents?: true

Size: 562 Bytes

Versions: 10

Compression:

Stored size: 562 Bytes

Contents

# frozen_string_literal: true

module TableSaw
  module Queries
    class TableColumns
      QUERY = <<~SQL
        select attname as colname
        from pg_catalog.pg_attribute
        where
                attrelid = $1::regclass
          and attnum > 0
          and attisdropped = false
        order by attnum
      SQL

      attr_reader :table

      def initialize(table)
        @table = table
      end

      def call
        TableSaw::Connection.with { |conn| conn.exec_params(QUERY, [table]) }.map { |r| r['colname'] }
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
table_saw-2.2.0 lib/table_saw/queries/table_columns.rb
table_saw-2.1.0 lib/table_saw/queries/table_columns.rb
table_saw-2.0.0 lib/table_saw/queries/table_columns.rb
table_saw-1.3.0 lib/table_saw/queries/table_columns.rb
table_saw-1.2.0 lib/table_saw/queries/table_columns.rb
table_saw-1.1.0 lib/table_saw/queries/table_columns.rb
table_saw-1.0.1 lib/table_saw/queries/table_columns.rb
table_saw-1.0.0 lib/table_saw/queries/table_columns.rb
table_saw-0.5.0 lib/table_saw/queries/table_columns.rb
table_saw-0.4.0 lib/table_saw/queries/table_columns.rb