Class: DataMapper::Adapters::MysqlAdapter
- Inherits:
-
DataObjectsAdapter
- Object
- DataObjectsAdapter
- DataMapper::Adapters::MysqlAdapter
- Defined in:
- lib/database_cleaner/data_mapper/truncation.rb
Instance Method Summary collapse
-
#disable_referential_integrity ⇒ Object
copied from activerecord.
-
#storage_names(repository = :default) ⇒ Object
taken from github.com/godfat/dm-mapping/tree/master.
- #truncate_table(table_name) ⇒ Object
Instance Method Details
#disable_referential_integrity ⇒ Object
copied from activerecord
27 28 29 30 31 32 33 34 35 |
# File 'lib/database_cleaner/data_mapper/truncation.rb', line 27 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
taken from github.com/godfat/dm-mapping/tree/master
18 19 20 |
# File 'lib/database_cleaner/data_mapper/truncation.rb', line 18 def storage_names(repository = :default) select 'SHOW TABLES' end |
#truncate_table(table_name) ⇒ Object
22 23 24 |
# File 'lib/database_cleaner/data_mapper/truncation.rb', line 22 def truncate_table(table_name) execute("TRUNCATE TABLE #{quote_name(table_name)};") end |