Class: RedshiftConnector::DeltaQuery
- Inherits:
-
Object
- Object
- RedshiftConnector::DeltaQuery
- Defined in:
- lib/redshift_connector/query.rb
Instance Method Summary collapse
- #description ⇒ Object
-
#initialize(schema:, table:, columns:, condition: nil) ⇒ DeltaQuery
constructor
A new instance of DeltaQuery.
- #table_spec ⇒ Object
- #to_sql ⇒ Object
Constructor Details
#initialize(schema:, table:, columns:, condition: nil) ⇒ DeltaQuery
Returns a new instance of DeltaQuery.
3 4 5 6 7 8 |
# File 'lib/redshift_connector/query.rb', line 3 def initialize(schema:, table:, columns:, condition: nil) @schema = schema @table = table @columns = columns @condition = condition end |
Instance Method Details
#description ⇒ Object
14 15 16 |
# File 'lib/redshift_connector/query.rb', line 14 def description "#{table_spec} (#{@columns.join(', ')}) where (#{@condition})" end |
#table_spec ⇒ Object
10 11 12 |
# File 'lib/redshift_connector/query.rb', line 10 def table_spec "#{@schema}.#{@table}" end |
#to_sql ⇒ Object
18 19 20 21 22 |
# File 'lib/redshift_connector/query.rb', line 18 def to_sql "select #{@columns.map {|c| %Q("#{c}") }.join(', ')}" \ + " from #{table_spec}" \ + (@condition ? " where #{@condition}" : '') end |