Module: Arel::Relation
- Includes:
- AttributeAccessable, DefaultOperations, Enumerable, Operable
- Included in:
- Array, Compound, Join, Nil, Table
- Defined in:
- lib/arel/algebra/relations/relation.rb,
lib/arel/engines/sql/relations/relation.rb,
lib/arel/algebra/relations/operations/join.rb,
lib/arel/algebra/relations/utilities/externalization.rb
Defined Under Namespace
Modules: AttributeAccessable, DefaultOperations, Enumerable, Operable
Constant Summary
collapse
- @@connection_tables_primary_keys =
{}
Instance Attribute Summary collapse
Instance Method Summary
collapse
#attributes, #groupings, #havings, #inserts, #joins, #locked, #orders, #projections, #skipped, #sources, #taken, #wheres
#[], #find_attribute_matching_attribute, #find_attribute_matching_name, #position_of
Methods included from Operable
#alias, #join, #lock, #outer_join
#delete, #insert, #update
Methods included from Enumerable
#each, #first
Instance Attribute Details
#count ⇒ Object
Returns the value of attribute count.
3
4
5
|
# File 'lib/arel/algebra/relations/relation.rb', line 3
def count
@count
end
|
Instance Method Details
#bind(relation) ⇒ Object
13
14
15
|
# File 'lib/arel/algebra/relations/relation.rb', line 13
def bind(relation)
self
end
|
#call ⇒ Object
9
10
11
|
# File 'lib/arel/algebra/relations/relation.rb', line 9
def call
engine.read(self)
end
|
#christener ⇒ Object
17
18
19
|
# File 'lib/arel/engines/sql/relations/relation.rb', line 17
def christener
@christener ||= Sql::Christener.new
end
|
#compiler ⇒ Object
5
6
7
8
9
10
11
|
# File 'lib/arel/engines/sql/relations/relation.rb', line 5
def compiler
@compiler ||= begin
"Arel::SqlCompiler::#{engine.adapter_name}Compiler".constantize.new(self)
rescue
Arel::SqlCompiler::GenericCompiler.new(self)
end
end
|
#exclusion_predicate_sql ⇒ Object
25
26
27
|
# File 'lib/arel/engines/sql/relations/relation.rb', line 25
def exclusion_predicate_sql
"NOT IN"
end
|
#externalizable? ⇒ Boolean
20
21
22
|
# File 'lib/arel/algebra/relations/utilities/externalization.rb', line 20
def externalizable?
false
end
|
#externalize ⇒ Object
16
17
18
|
# File 'lib/arel/algebra/relations/utilities/externalization.rb', line 16
def externalize
@externalized ||= externalizable?? Externalization.new(self) : self
end
|
#inclusion_predicate_sql ⇒ Object
21
22
23
|
# File 'lib/arel/engines/sql/relations/relation.rb', line 21
def inclusion_predicate_sql
"IN"
end
|
#join? ⇒ Boolean
65
66
67
|
# File 'lib/arel/algebra/relations/operations/join.rb', line 65
def join?
false
end
|
#primary_key ⇒ Object
29
30
31
32
33
34
35
36
37
|
# File 'lib/arel/engines/sql/relations/relation.rb', line 29
def primary_key
connection_id = engine.connection.object_id
if @@connection_tables_primary_keys[connection_id] && @@connection_tables_primary_keys[connection_id].has_key?(table.name)
@@connection_tables_primary_keys[connection_id][table.name]
else
@@connection_tables_primary_keys[connection_id] ||= {}
@@connection_tables_primary_keys[connection_id][table.name] = engine.connection.primary_key(table.name)
end
end
|
#session ⇒ Object
5
6
7
|
# File 'lib/arel/algebra/relations/relation.rb', line 5
def session
Session.new
end
|
#to_sql(formatter = Sql::SelectStatement.new(self)) ⇒ Object
13
14
15
|
# File 'lib/arel/engines/sql/relations/relation.rb', line 13
def to_sql(formatter = Sql::SelectStatement.new(self))
formatter.select compiler.select_sql, self
end
|