Class: Prequel::Sql::Subquery

Inherits:
Query
  • Object
show all
Includes:
NamedTableRef
Defined in:
lib/prequel/sql/subquery.rb

Instance Attribute Summary collapse

Attributes inherited from Query

#conditions, #literals, #query_columns, #select_list, #singular_table_refs, #subquery_count, #table_ref, #tuple_builder

Instance Method Summary collapse

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

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/prequel/sql/subquery.rb', line 6

def name
  @name
end

#parentObject (readonly)

Returns the value of attribute parent.



6
7
8
# File 'lib/prequel/sql/subquery.rb', line 6

def parent
  @parent
end

#relationObject (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_sqlObject



16
17
18
# File 'lib/prequel/sql/subquery.rb', line 16

def to_sql
  ['(', sql_string, ') as ', name].join
end