Class: DataMapper::Adapters::MysqlAdapter

Inherits:
DataObjectsAdapter show all
Defined in:
lib/database_cleaner/data_mapper/truncation.rb

Instance Method Summary collapse

Methods inherited from DataObjectsAdapter

#truncate_tables

Instance Method Details

#disable_referential_integrityObject

copied from activerecord



33
34
35
36
37
38
39
40
41
# File 'lib/database_cleaner/data_mapper/truncation.rb', line 33

def disable_referential_integrity
  old = select("SELECT @@FOREIGN_KEY_CHECKS;")
  begin
    execute("SET FOREIGN_KEY_CHECKS = 0;")
    yield
  ensure
    execute("SET FOREIGN_KEY_CHECKS = ?", *old)
  end
end

#storage_names(repository = :default) ⇒ Object



24
25
26
# File 'lib/database_cleaner/data_mapper/truncation.rb', line 24

def storage_names(repository = :default)
  select 'SHOW TABLES'
end

#truncate_table(table_name) ⇒ Object



28
29
30
# File 'lib/database_cleaner/data_mapper/truncation.rb', line 28

def truncate_table(table_name)
  execute("TRUNCATE TABLE #{quote_name(table_name)};")
end