Class: RedshiftConnector::SelectAllQuery

Inherits:
Object
  • Object
show all
Defined in:
lib/redshift_connector/query.rb

Instance Method Summary collapse

Constructor Details

#initialize(schema:, table:, columns:) ⇒ SelectAllQuery

Returns a new instance of SelectAllQuery.



26
27
28
29
30
# File 'lib/redshift_connector/query.rb', line 26

def initialize(schema:, table:, columns:)
  @schema = schema
  @table = table
  @columns = columns
end

Instance Method Details

#descriptionObject



36
37
38
# File 'lib/redshift_connector/query.rb', line 36

def description
  "#{table_spec} (#{@columns.join(', ')})"
end

#table_specObject



32
33
34
# File 'lib/redshift_connector/query.rb', line 32

def table_spec
  "#{@schema}.#{@table}"
end

#to_sqlObject



40
41
42
43
# File 'lib/redshift_connector/query.rb', line 40

def to_sql
  "select #{@columns.map {|c| %Q("#{c}") }.join(', ')}" \
      + " from #{table_spec}"
end