Class: Seaquel::AST::Column

Inherits:
Expression show all
Defined in:
lib/seaquel/ast/column.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Expression

#as, #asc, binop, #desc, joinop, #lisp_inspect, unaryop

Constructor Details

#initialize(name, table = nil) ⇒ Column

Returns a new instance of Column.



9
10
11
12
# File 'lib/seaquel/ast/column.rb', line 9

def initialize name, table=nil
  @name = name
  @table = table
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/seaquel/ast/column.rb', line 6

def name
  @name
end

#tableObject (readonly)

Returns the value of attribute table.



7
8
9
# File 'lib/seaquel/ast/column.rb', line 7

def table
  @table
end

Instance Method Details

#as_column_reference(quoter) ⇒ Object

Returns an SQL column reference, excluding table name.



42
43
44
# File 'lib/seaquel/ast/column.rb', line 42

def as_column_reference quoter
  quoter.column(name)
end

#as_full_reference(quoter) ⇒ Object

Returns an SQL column reference, including the table name.



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/seaquel/ast/column.rb', line 28

def as_full_reference quoter
  parts = []

  if table
    parts << table.as_column_prefix(quoter)
  end

  parts << as_column_reference(quoter)

  parts.join('.')
end

#inspectObject



46
47
48
49
50
51
52
# File 'lib/seaquel/ast/column.rb', line 46

def inspect
  if table
    lisp_inspect(:column, name, table)
  else
    lisp_inspect(:column, name)
  end
end

#to(value) ⇒ Object

Set the column to value.



16
17
18
# File 'lib/seaquel/ast/column.rb', line 16

def to value
  Assign.new(self, value)
end

#visit(visitor) ⇒ Object

Visits the column as part of sql generation.



22
23
24
# File 'lib/seaquel/ast/column.rb', line 22

def visit visitor
  visitor.visit_column self
end