Class: FlareUp::Command::DropTable

Inherits:
Base
  • Object
show all
Defined in:
lib/flare_up/command/drop_table.rb

Instance Attribute Summary

Attributes inherited from Base

#table_name

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from FlareUp::Command::Base

Instance Method Details

#execute(connection) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/flare_up/command/drop_table.rb', line 10

def execute(connection)
  begin
    connection.execute(get_command)
    []
  rescue PG::InternalError => e
    case e.message
      when /Check 'stl_load_errors' system table for details/
        return STLLoadErrorFetcher.fetch_errors(connection)
      when /PG::SyntaxError/
        matches = /syntax error (.+) \(PG::SyntaxError\)/.match(e.message)
        raise SyntaxError, "Syntax error in the DROP TABLE command: [#{matches[1]}]."
      else
        raise e
    end
  end
end

#get_commandObject



6
7
8
# File 'lib/flare_up/command/drop_table.rb', line 6

def get_command
  "DROP TABLE #{@table_name} #{@options}"
end