Module: DatabaseCleaner::ConnectionAdapters::TruncateOrDelete

Defined in:
lib/database_cleaner/active_record/truncation.rb

Instance Method Summary collapse

Instance Method Details

#truncate_table(table_name) ⇒ Object


117
118
119
120
121
122
123
# File 'lib/database_cleaner/active_record/truncation.rb', line 117

def truncate_table(table_name)
  begin
    execute("TRUNCATE TABLE #{quote_table_name(table_name)};")
  rescue ::ActiveRecord::StatementInvalid
    execute("DELETE FROM #{quote_table_name(table_name)};")
  end
end