alias()
click to toggle source
154: def alias
155: Alias.new(self)
156: end
bind(relation)
click to toggle source
21: def bind(relation)
22: self
23: end
call()
click to toggle source
17: def call
18: engine.read(self)
19: end
christener()
click to toggle source
48: def christener
49: @christener ||= Sql::Christener.new
50: end
compiler()
click to toggle source
33: def compiler
34: @compiler ||= begin
35: Arel::SqlCompiler.const_get("#{engine.adapter_name}Compiler").new(self)
36: rescue
37: Arel::SqlCompiler::GenericCompiler.new(self)
38: end
39: end
delete()
click to toggle source
166: def delete
167: session.delete Deletion.new(self)
168: end
each()
click to toggle source
101: def each
102: session.read(self).each { |e| yield e }
103: end
exclusion_predicate_sql()
click to toggle source
56: def exclusion_predicate_sql
57: "NOT IN"
58: end
externalizable?()
click to toggle source
29: def externalizable?
30: false
31: end
externalize()
click to toggle source
25: def externalize
26: @externalized ||= externalizable?? Externalization.new(self) : self
27: end
from(thing)
click to toggle source
146: def from thing
147: From.new self, thing
148: end
from_clauses()
click to toggle source
81: def from_clauses
82: sources.empty? ? table_sql : sources
83: end
group_clauses()
click to toggle source
89: def group_clauses
90: groupings.collect { |g| g.to_sql(Sql::GroupClause.new(self)) }
91: end
having_clauses()
click to toggle source
93: def having_clauses
94: havings.collect { |g| g.to_sql(Sql::HavingClause.new(self)) }
95: end
inclusion_predicate_sql()
click to toggle source
52: def inclusion_predicate_sql
53: "IN"
54: end
insert(record)
click to toggle source
158: def insert(record)
159: session.create Insert.new(self, record)
160: end
join(other_relation = nil, join_class = InnerJoin)
click to toggle source
105: def join(other_relation = nil, join_class = InnerJoin)
106: case other_relation
107: when String
108: StringJoin.new(self, other_relation)
109: when Relation
110: JoinOperation.new(join_class, self, other_relation)
111: else
112: self
113: end
114: end
join?()
click to toggle source
13: def join?
14: false
15: end
lock(locking = true)
click to toggle source
150: def lock(locking = true)
151: Lock.new(self, locking)
152: end
order_clauses()
click to toggle source
97: def order_clauses
98: orders.collect { |o| o.to_sql(Sql::OrderClause.new(self)) }
99: end
outer_join(other_relation = nil)
click to toggle source
116: def outer_join(other_relation = nil)
117: join(other_relation, OuterJoin)
118: end
primary_key()
click to toggle source
60: def primary_key
61: connection_id = engine.connection.object_id
62: if @@connection_tables_primary_keys[connection_id] && @@connection_tables_primary_keys[connection_id].has_key?(table.name)
63: @@connection_tables_primary_keys[connection_id][table.name]
64: else
65: @@connection_tables_primary_keys[connection_id] ||= {}
66: @@connection_tables_primary_keys[connection_id][table.name] = engine.connection.primary_key(table.name)
67: end
68: end
project(*args)
click to toggle source
130: def project *args
131: args.empty? ? self : Project.new(self, args)
132: end
select_clauses()
click to toggle source
70: def select_clauses
71: attributes.map { |a|
72: case a
73: when Value
74: a.value
75: else
76: a.to_sql(Sql::SelectClause.new(self))
77: end
78: }
79: end
session()
click to toggle source
9: def session
10: Session.instance
11: end
skip(thing = nil)
click to toggle source
138: def skip thing = nil
139: thing ? Skip.new(self, thing) : self
140: end
take(count)
click to toggle source
142: def take count
143: Take.new self, count
144: end
to_sql(formatter = nil)
click to toggle source
41: def to_sql(formatter = nil)
42: sql = compiler.select_sql
43:
44: return sql unless formatter
45: formatter.select sql, self
46: end
update(assignments)
click to toggle source
162: def update(assignments)
163: session.update Update.new(self, assignments)
164: end
where(clause = nil)
click to toggle source
134: def where clause = nil
135: clause ? Where.new(self, [clause].flatten) : self
136: end
where_clauses()
click to toggle source
85: def where_clauses
86: wheres.map { |w| w.value }
87: end