Class: Prequel::Sql::DerivedQueryColumn
- Inherits:
-
Object
- Object
- Prequel::Sql::DerivedQueryColumn
- Defined in:
- lib/prequel/sql/derived_query_column.rb
Instance Attribute Summary collapse
-
#expression ⇒ Object
readonly
Returns the value of attribute expression.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#subquery ⇒ Object
readonly
Returns the value of attribute subquery.
Instance Method Summary collapse
-
#initialize(subquery, name, expression) ⇒ DerivedQueryColumn
constructor
A new instance of DerivedQueryColumn.
- #qualified_name ⇒ Object
- #to_select_clause_sql ⇒ Object
- #to_sql ⇒ Object
Constructor Details
#initialize(subquery, name, expression) ⇒ DerivedQueryColumn
Returns a new instance of DerivedQueryColumn.
6 7 8 |
# File 'lib/prequel/sql/derived_query_column.rb', line 6 def initialize(subquery, name, expression) @subquery, @name, @expression = subquery, name, expression end |
Instance Attribute Details
#expression ⇒ Object (readonly)
Returns the value of attribute expression.
4 5 6 |
# File 'lib/prequel/sql/derived_query_column.rb', line 4 def expression @expression end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/prequel/sql/derived_query_column.rb', line 4 def name @name end |
#subquery ⇒ Object (readonly)
Returns the value of attribute subquery.
4 5 6 |
# File 'lib/prequel/sql/derived_query_column.rb', line 4 def subquery @subquery end |
Instance Method Details
#qualified_name ⇒ Object
18 19 20 |
# File 'lib/prequel/sql/derived_query_column.rb', line 18 def qualified_name "#{subquery.name}__#{name}" end |
#to_select_clause_sql ⇒ Object
14 15 16 |
# File 'lib/prequel/sql/derived_query_column.rb', line 14 def to_select_clause_sql "#{expression.to_sql} as #{name}" end |
#to_sql ⇒ Object
10 11 12 |
# File 'lib/prequel/sql/derived_query_column.rb', line 10 def to_sql "#{subquery.name}.#{name}" end |