[](name)
click to toggle source
96: def [] name
97: return nil unless table_exists?
98:
99: name = name.to_sym
100: columns.find { |column| column.name == name }
101: end
alias()
click to toggle source
37: def alias
38: Nodes::TableAlias.new("#{name}_2", self).tap do |node|
39: @aliases << node
40: end
41: end
columns()
click to toggle source
91: def columns
92: @columns ||=
93: attributes_for @engine.connection.columns(@name, "#{@name} Columns")
94: end
from(table)
click to toggle source
43: def from table
44: SelectManager.new(@engine, table)
45: end
group(*columns)
click to toggle source
63: def group *columns
64: from(self).group(*columns)
65: end
having(expr)
click to toggle source
87: def having expr
88: from(self).having expr
89: end
join(relation, klass = Nodes::InnerJoin)
click to toggle source
51: def join relation, klass = Nodes::InnerJoin
52: return from(self) unless relation
53:
54: case relation
55: when String, Nodes::SqlLiteral
56: raise if relation.blank?
57: from Nodes::StringJoin.new(self, relation)
58: else
59: from klass.new(self, relation, nil)
60: end
61: end
joins(manager)
click to toggle source
47: def joins manager
48: nil
49: end
order(*expr)
click to toggle source
67: def order *expr
68: from(self).order(*expr)
69: end
primary_key()
click to toggle source
29: def primary_key
30: @primary_key ||= begin
31: primary_key_name = @engine.connection.primary_key(name)
32:
33: primary_key_name && self[primary_key_name]
34: end
35: end
project(*things)
click to toggle source
75: def project *things
76: from(self).project(*things)
77: end
select_manager()
click to toggle source
103: def select_manager
104: SelectManager.new(@engine)
105: end
skip(amount)
click to toggle source
83: def skip amount
84: from(self).skip amount
85: end
take(amount)
click to toggle source
79: def take amount
80: from(self).take amount
81: end
where(condition)
click to toggle source
71: def where condition
72: from(self).where condition
73: end