Class: TableSaw::Queries::TableColumns

Inherits:
Object
  • Object
show all
Defined in:
lib/table_saw/queries/table_columns.rb

Constant Summary collapse

QUERY =
"select attname as colname\nfrom pg_catalog.pg_attribute\nwhere\n        attrelid = $1::regclass\n  and attnum > 0\n  and attisdropped = false\norder by attnum\n"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(table) ⇒ TableColumns

Returns a new instance of TableColumns.



20
21
22
# File 'lib/table_saw/queries/table_columns.rb', line 20

def initialize(table)
  @table = table
end

Instance Attribute Details

#tableObject (readonly)

Returns the value of attribute table.



18
19
20
# File 'lib/table_saw/queries/table_columns.rb', line 18

def table
  @table
end

Instance Method Details

#callObject



24
25
26
# File 'lib/table_saw/queries/table_columns.rb', line 24

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