Sha256: f33e4fb966ed7f401a6c200f837b64c0a6b502d7e64bad536aea6f586311f582

Contents?: true

Size: 819 Bytes

Versions: 1

Compression:

Stored size: 819 Bytes

Contents

module FlareUp
  module Command
    class DropTable < Command::Base

      # http://docs.aws.amazon.com/redshift/latest/dg/r_DROP_TABLE.html
      def get_command
        "DROP TABLE #{@table_name} #{@options}"
      end

      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
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
flare-up-0.9 lib/flare_up/command/drop_table.rb