Support table truncation in DB2 (>= 9.7)

This commit is contained in:
Samer Abukhait 2011-01-18 11:21:40 -08:00 committed by Ben Mabey
parent c7f34e6f9f
commit ef585d70d1
5 changed files with 15 additions and 1 deletions

View file

@ -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 file

@ -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 file

@ -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 file

@ -34,6 +34,12 @@ module ActiveRecord
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 file

@ -5,8 +5,11 @@ require 'database_cleaner/active_record/truncation'
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