Class: ClickHouse::Definition::ColumnSet
- Inherits:
-
Object
- Object
- ClickHouse::Definition::ColumnSet
- Defined in:
- lib/click_house/definition/column_set.rb
Constant Summary collapse
- TYPES =
ClickHouse.type_names(nullable: false).map { |s| s.sub('%s', "'%s'") }.freeze
Class Method Summary collapse
Instance Method Summary collapse
- #columns ⇒ Object
-
#initialize {|_self| ... } ⇒ ColumnSet
constructor
A new instance of ColumnSet.
- #nested(name, &block) ⇒ Object (also: #Nested)
- #push(sql) ⇒ Object (also: #<<)
- #to_s ⇒ Object
Constructor Details
#initialize {|_self| ... } ⇒ ColumnSet
Returns a new instance of ColumnSet.
35 36 37 |
# File 'lib/click_house/definition/column_set.rb', line 35 def initialize yield(self) if block_given? end |
Class Method Details
.method_name_for_type(type) ⇒ Object
11 12 13 |
# File 'lib/click_house/definition/column_set.rb', line 11 def method_name_for_type(type) type.sub(/\(.+/, '') end |
Instance Method Details
#columns ⇒ Object
39 40 41 |
# File 'lib/click_house/definition/column_set.rb', line 39 def columns @columns ||= [] end |
#nested(name, &block) ⇒ Object Also known as: Nested
53 54 55 |
# File 'lib/click_house/definition/column_set.rb', line 53 def nested(name, &block) columns << "#{name} Nested #{ColumnSet.new(&block)}" end |
#push(sql) ⇒ Object Also known as: <<
59 60 61 |
# File 'lib/click_house/definition/column_set.rb', line 59 def push(sql) columns << sql end |
#to_s ⇒ Object
43 44 45 46 47 |
# File 'lib/click_house/definition/column_set.rb', line 43 def to_s <<~SQL ( #{columns.map(&:to_s).join(', ')} ) SQL end |