Class: FlareUp::Command::CreateTable
- Defined in:
- lib/flare_up/command/create_table.rb
Instance Attribute Summary collapse
-
#columns ⇒ Object
Returns the value of attribute columns.
Attributes inherited from Base
Instance Method Summary collapse
- #execute(connection) ⇒ Object
- #get_command ⇒ Object
-
#initialize(*args) ⇒ CreateTable
constructor
A new instance of CreateTable.
Constructor Details
#initialize(*args) ⇒ CreateTable
Returns a new instance of CreateTable.
7 8 9 10 |
# File 'lib/flare_up/command/create_table.rb', line 7 def initialize(*args) @columns = [] super end |
Instance Attribute Details
#columns ⇒ Object
Returns the value of attribute columns.
5 6 7 |
# File 'lib/flare_up/command/create_table.rb', line 5 def columns @columns end |
Instance Method Details
#execute(connection) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/flare_up/command/create_table.rb', line 32 def execute(connection) begin connection.execute(get_command) [] rescue PG::InternalError => e case e. when /Check 'stl_load_errors' system table for details/ return STLLoadErrorFetcher.fetch_errors(connection) when /PG::SyntaxError/ matches = /syntax error (.+) \(PG::SyntaxError\)/.match(e.) raise SyntaxError, "Syntax error in the CREATE TABLE command: [#{matches[1]}]." else raise e end end end |
#get_command ⇒ Object
14 15 16 |
# File 'lib/flare_up/command/create_table.rb', line 14 def get_command "CREATE TABLE #{@table_name} #{get_columns} #{@options}" end |