Class: Chicago::Schema::VirtualColumn

Inherits:
QualifiedColumn show all
Defined in:
lib/chicago/schema/query_column.rb

Overview

Allows querying a column that doesn’t exist in the database, but is defined as a calculation in the column definition.

Virtual columns are currently assumed to be calculated measures

  • filters will appear in the HAVING clause, not the WHERE clause

of the SQL statement.

Instance Attribute Summary

Attributes inherited from AbstractQualifiedColumn

#column_alias, #count_name, #owner, #select_name

Instance Method Summary collapse

Methods inherited from AbstractQualifiedColumn

#calculate, #pivot

Methods inherited from QueryColumn

column, #method_missing, #qualified_label

Constructor Details

#initialize(owner, column, column_alias, table_label) ⇒ VirtualColumn

Returns a new instance of VirtualColumn.



115
116
117
118
# File 'lib/chicago/schema/query_column.rb', line 115

def initialize(owner, column, column_alias, table_label)
  super
  @select_name = @column.calculation
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Chicago::Schema::QueryColumn

Instance Method Details

#filter_dataset(ds, filter) ⇒ Object



124
125
126
# File 'lib/chicago/schema/query_column.rb', line 124

def filter_dataset(ds, filter)
  ds.having(filter)
end

#group_nameObject



120
121
122
# File 'lib/chicago/schema/query_column.rb', line 120

def group_name
  nil
end