Parent

Files

Class/Module Index [+]

Quicksearch

DatabaseCleaner::Sequel::Truncation

Public Instance Methods

clean() click to toggle source
# File lib/database_cleaner/sequel/truncation.rb, line 10
def clean
  case db.database_type
  when :postgres
    # PostgreSQL requires all tables with FKs to be truncates in the same command, or have the CASCADE keyword
    # appended. Bulk truncation without CASCADE is:
    # * Safer. Tables outside of tables_to_truncate won't be affected.
    # * Faster. Less roundtrips to the db.
    unless (tables= tables_to_truncate(db)).empty?
      all_tables= tables.map{|t| %["#{t}"]}.join ','
      db.run "TRUNCATE TABLE #{all_tables};"
    end
  else
    # Truncate each table normally
    each_table do |db, table|
      db[table].truncate
    end
  end
end
each_table() click to toggle source
# File lib/database_cleaner/sequel/truncation.rb, line 29
def each_table
  tables_to_truncate(db).each do |table|
    yield db, table
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.