mirror of
https://github.com/DatabaseCleaner/database_cleaner
synced 2023-03-27 23:22:03 -04:00
Support table truncation in DB2 (>= 9.7)
This commit is contained in:
parent
c7f34e6f9f
commit
ef585d70d1
5 changed files with 15 additions and 1 deletions
1
Gemfile
1
Gemfile
|
@ -32,6 +32,7 @@ group :development do
|
||||||
gem "tzinfo", "0.3.22"
|
gem "tzinfo", "0.3.22"
|
||||||
gem "mongo_mapper", "0.8.2"
|
gem "mongo_mapper", "0.8.2"
|
||||||
gem "couch_potato", "0.3.0"
|
gem "couch_potato", "0.3.0"
|
||||||
|
gem "ibm_db"
|
||||||
end
|
end
|
||||||
|
|
||||||
group :test do
|
group :test do
|
||||||
|
|
|
@ -148,6 +148,7 @@ DEPENDENCIES
|
||||||
datamapper (= 1.0.0)
|
datamapper (= 1.0.0)
|
||||||
dm-migrations (= 1.0.0)
|
dm-migrations (= 1.0.0)
|
||||||
dm-sqlite-adapter (= 1.0.0)
|
dm-sqlite-adapter (= 1.0.0)
|
||||||
|
ibm_db
|
||||||
jeweler
|
jeweler
|
||||||
json_pure
|
json_pure
|
||||||
mongo_mapper (= 0.8.2)
|
mongo_mapper (= 0.8.2)
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
== 0.6.2 (in git)
|
== 0.6.2 (in git)
|
||||||
|
|
||||||
|
=== New Features
|
||||||
|
* Support IBM_DB Adapter for table truncation. This is for DB2 >= 9.7 (GH-39 Samer Abukhait)
|
||||||
|
|
||||||
=== Bugfixes
|
=== Bugfixes
|
||||||
* Reversed GH-41 after larger community discussion. Mongo indexes are no longer dropped. (Ben Mabey)
|
* Reversed GH-41 after larger community discussion. Mongo indexes are no longer dropped. (Ben Mabey)
|
||||||
* Truncation strategy works on SqlServer tables with FKs. (GH-33, Hugo Freire)
|
* Truncation strategy works on SqlServer tables with FKs. (GH-33, Hugo Freire)
|
||||||
|
|
|
@ -34,6 +34,12 @@ module ActiveRecord
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class IBM_DBAdapter < AbstractAdapter
|
||||||
|
def truncate_table(table_name)
|
||||||
|
execute("TRUNCATE #{quote_table_name(table_name)} IMMEDIATE")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
class SQLite3Adapter < SQLITE_ADAPTER_PARENT
|
class SQLite3Adapter < SQLITE_ADAPTER_PARENT
|
||||||
def delete_table(table_name)
|
def delete_table(table_name)
|
||||||
execute("DELETE FROM #{quote_table_name(table_name)};")
|
execute("DELETE FROM #{quote_table_name(table_name)};")
|
||||||
|
|
|
@ -5,8 +5,11 @@ require 'database_cleaner/active_record/truncation'
|
||||||
|
|
||||||
module ActiveRecord
|
module ActiveRecord
|
||||||
module ConnectionAdapters
|
module ConnectionAdapters
|
||||||
[MysqlAdapter, Mysql2Adapter, SQLite3Adapter, JdbcAdapter, PostgreSQLAdapter].each do |adapter|
|
[MysqlAdapter, Mysql2Adapter, SQLite3Adapter, JdbcAdapter, PostgreSQLAdapter, IBM_DBAdapter].each do |adapter|
|
||||||
describe adapter, "#truncate_table" do
|
describe adapter, "#truncate_table" do
|
||||||
|
it "responds" do
|
||||||
|
adapter.new("foo").should respond_to(:truncate_table)
|
||||||
|
end
|
||||||
it "should truncate the table"
|
it "should truncate the table"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue