Class: ConceptQL::TempTable
- Inherits:
-
Object
- Object
- ConceptQL::TempTable
- Defined in:
- lib/conceptql/utils/temp_table.rb
Overview
TempTable coordinates the creation of any temporary tables a statement might need.
Currently, temp tables are used to share a set of results when a Recall operator is present in a statement.
It also provides an API to generate the SQL that Sequel would use to create and populate the temp table
Instance Attribute Summary collapse
-
#operator ⇒ Object
readonly
Returns the value of attribute operator.
Instance Method Summary collapse
- #build(db) ⇒ Object
- #from(db) ⇒ Object
-
#initialize(operator, db) ⇒ TempTable
constructor
A new instance of TempTable.
- #sql(db) ⇒ Object
Constructor Details
#initialize(operator, db) ⇒ TempTable
14 15 16 17 |
# File 'lib/conceptql/utils/temp_table.rb', line 14 def initialize(operator, db) @operator = operator fake_it!(db) end |
Instance Attribute Details
#operator ⇒ Object (readonly)
Returns the value of attribute operator.
13 14 15 |
# File 'lib/conceptql/utils/temp_table.rb', line 13 def operator @operator end |
Instance Method Details
#build(db) ⇒ Object
19 20 21 |
# File 'lib/conceptql/utils/temp_table.rb', line 19 def build(db) @built ||= build_it(db) end |
#from(db) ⇒ Object
30 31 32 |
# File 'lib/conceptql/utils/temp_table.rb', line 30 def from(db) db[table_name] end |
#sql(db) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/conceptql/utils/temp_table.rb', line 23 def sql(db) # Sequel doesn't (currently) provide an API for getting the SQL for the # creation of tables, so we're calling one of the private methods sql = db[db.send(:create_table_as_sql, table_name, operator.evaluate(db), temp: true)].sql ["-- #{operator.label}", sql].join("\n") end |