Class: Insertica::Column
- Inherits:
-
Object
- Object
- Insertica::Column
- Defined in:
- lib/insertica/column.rb
Constant Summary collapse
- ESCAPE_CHARACTERS =
["\n", "\t", "\""]
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#type ⇒ Object
Returns the value of attribute type.
-
#values ⇒ Object
Returns the value of attribute values.
Instance Method Summary collapse
- #definition ⇒ Object
- #filler_definition ⇒ Object
- #finalize ⇒ Object
- #fix_nulls_definition ⇒ Object
-
#initialize(name, values = []) ⇒ Column
constructor
A new instance of Column.
Constructor Details
#initialize(name, values = []) ⇒ Column
Returns a new instance of Column.
11 12 13 14 15 |
# File 'lib/insertica/column.rb', line 11 def initialize(name, values = []) @name = name @type = nil @values = values end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/insertica/column.rb', line 7 def name @name end |
#type ⇒ Object
Returns the value of attribute type.
9 10 11 |
# File 'lib/insertica/column.rb', line 9 def type @type end |
#values ⇒ Object
Returns the value of attribute values.
8 9 10 |
# File 'lib/insertica/column.rb', line 8 def values @values end |
Instance Method Details
#definition ⇒ Object
24 25 26 |
# File 'lib/insertica/column.rb', line 24 def definition "#{@name} #{@type}" end |
#filler_definition ⇒ Object
28 29 30 |
# File 'lib/insertica/column.rb', line 28 def filler_definition "#{@name}_filler FILLER VARCHAR" end |
#finalize ⇒ Object
17 18 19 20 21 22 |
# File 'lib/insertica/column.rb', line 17 def finalize @type = ColumnType.new(@values) escape_strings if @type.needs_escaping? self end |
#fix_nulls_definition ⇒ Object
32 33 34 |
# File 'lib/insertica/column.rb', line 32 def fix_nulls_definition "#{@name} AS CASE WHEN #{@name}_filler = '' THEN NULL ELSE #{@name}_filler::#{@type} END" end |