Class: Seaquel::AST::Column
- Inherits:
-
Expression
- Object
- Expression
- Seaquel::AST::Column
- Defined in:
- lib/seaquel/ast/column.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#table ⇒ Object
readonly
Returns the value of attribute table.
Instance Method Summary collapse
-
#as_column_reference(quoter) ⇒ Object
Returns an SQL column reference, excluding table name.
-
#as_full_reference(quoter) ⇒ Object
Returns an SQL column reference, including the table name.
-
#initialize(name, table = nil) ⇒ Column
constructor
A new instance of Column.
- #inspect ⇒ Object
-
#to(value) ⇒ Object
Set the column to value.
-
#visit(visitor) ⇒ Object
Visits the column as part of sql generation.
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
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/seaquel/ast/column.rb', line 6 def name @name end |
#table ⇒ Object (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 |
#inspect ⇒ Object
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 |