Browse files

Support table truncation in DB2 (>= 9.7)

  • Loading branch information...
1 parent c7f34e6 commit ef585d70d11a188c622f4cb9b6a572099ce365c6 Samer Abukhait committed with bmabey Jan 18, 2011
View
1 Gemfile
@@ -32,6 +32,7 @@ group :development do
gem "tzinfo", "0.3.22"
gem "mongo_mapper", "0.8.2"
gem "couch_potato", "0.3.0"
+ gem "ibm_db"
end
group :test do
View
1 Gemfile.lock
@@ -148,6 +148,7 @@ DEPENDENCIES
datamapper (= 1.0.0)
dm-migrations (= 1.0.0)
dm-sqlite-adapter (= 1.0.0)
+ ibm_db
jeweler
json_pure
mongo_mapper (= 0.8.2)
View
3 History.txt
@@ -1,5 +1,8 @@
== 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
* 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)
View
6 lib/database_cleaner/active_record/truncation.rb
@@ -34,6 +34,12 @@ def truncate_table(table_name)
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
def delete_table(table_name)
execute("DELETE FROM #{quote_table_name(table_name)};")
View
5 spec/database_cleaner/active_record/truncation_spec.rb
@@ -5,8 +5,11 @@
module ActiveRecord
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
+ it "responds" do
+ adapter.new("foo").should respond_to(:truncate_table)
+ end
it "should truncate the table"
end
end

0 comments on commit ef585d7

Please sign in to comment.