Class: DataMapper::Adapters::MysqlAdapter

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

Instance Method Summary collapse

Instance Method Details

#disable_referential_integrityObject

copied from activerecord



26
27
28
29
30
31
32
33
34
# File 'lib/database_cleaner/data_mapper/truncation.rb', line 26

def disable_referential_integrity
  old = query("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



17
18
19
# File 'lib/database_cleaner/data_mapper/truncation.rb', line 17

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

#truncate_table(table_name) ⇒ Object



21
22
23
# File 'lib/database_cleaner/data_mapper/truncation.rb', line 21

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