Class: Prequel::Sql::Subquery
- Includes:
- NamedTableRef
- Defined in:
- lib/prequel/sql/subquery.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#relation ⇒ Object
readonly
Returns the value of attribute relation.
Attributes inherited from Query
#conditions, #literals, #query_columns, #select_list, #singular_table_refs, #subquery_count, #table_ref, #tuple_builder
Instance Method Summary collapse
- #build_tuple(field_values) ⇒ Object
-
#initialize(parent, relation, name) ⇒ Subquery
constructor
A new instance of Subquery.
- #to_sql ⇒ Object
Methods inherited from Query
#add_condition, #add_literal, #add_singular_table_ref, #add_subquery, #all, #build, #first, #resolve_derived_column, #result_set
Constructor Details
#initialize(parent, relation, name) ⇒ Subquery
Returns a new instance of Subquery.
9 10 11 12 |
# File 'lib/prequel/sql/subquery.rb', line 9 def initialize(parent, relation, name) @parent, @name = parent, name super(relation) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/prequel/sql/subquery.rb', line 6 def name @name end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
6 7 8 |
# File 'lib/prequel/sql/subquery.rb', line 6 def parent @parent end |
#relation ⇒ Object (readonly)
Returns the value of attribute relation.
6 7 8 |
# File 'lib/prequel/sql/subquery.rb', line 6 def relation @relation end |
Instance Method Details
#build_tuple(field_values) ⇒ Object
20 21 22 |
# File 'lib/prequel/sql/subquery.rb', line 20 def build_tuple(field_values) tuple_builder.build_tuple(extract_field_values(field_values)) end |
#to_sql ⇒ Object
16 17 18 |
# File 'lib/prequel/sql/subquery.rb', line 16 def to_sql ['(', sql_string, ') as ', name].join end |