database_cleaner 0.6.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +7 -0
- data/Rakefile +15 -0
- data/VERSION.yml +3 -4
- data/examples/Gemfile +1 -0
- data/lib/database_cleaner/active_record/truncation.rb +11 -1
- data/lib/database_cleaner/mongo/truncation.rb +3 -8
- data/spec/database_cleaner/active_record/truncation_spec.rb +4 -1
- metadata +4 -10
- data/examples/config/database.yml +0 -7
- data/examples/db/activerecord_one.db +0 -0
- data/examples/db/activerecord_two.db +0 -0
- data/examples/db/datamapper_default.db +0 -0
- data/examples/db/datamapper_one.db +0 -0
- data/examples/db/datamapper_two.db +0 -0
data/History.txt
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
== 0.6.2 (in git)
|
2
2
|
|
3
|
+
=== New Features
|
4
|
+
* Support IBM_DB Adapter for table truncation. This is for DB2 >= 9.7 (GH-39 Samer Abukhait)
|
5
|
+
|
6
|
+
=== Bugfixes
|
7
|
+
* Reversed GH-41 after larger community discussion. Mongo indexes are no longer dropped. (Ben Mabey)
|
8
|
+
* Truncation strategy works on SqlServer tables with FKs. (GH-33, Hugo Freire)
|
9
|
+
|
3
10
|
== 0.6.1 2011-01-27
|
4
11
|
|
5
12
|
=== New Features
|
data/Rakefile
CHANGED
@@ -48,3 +48,18 @@ rescue LoadError
|
|
48
48
|
end
|
49
49
|
|
50
50
|
task :default => [:spec, :features]
|
51
|
+
|
52
|
+
|
53
|
+
desc "Cleans the project of any tmp file that should not be included in the gemspec."
|
54
|
+
task :clean do
|
55
|
+
["examples/config/database.yml", "examples/db/activerecord_one.db", "examples/db/activerecord_two.db", "examples/db/datamapper_default.db",
|
56
|
+
"examples/db/datamapper_one.db", "examples/db/datamapper_two.db"].each do |f|
|
57
|
+
FileUtils.rm_f(f)
|
58
|
+
end
|
59
|
+
%w[*.sqlite3 *.log].each do |pattern|
|
60
|
+
`find . -name "#{pattern}" -delete`
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
desc "Cleans the dir and builds the gem"
|
65
|
+
task :prep => [:clean, :gemspec, :build]
|
data/VERSION.yml
CHANGED
data/examples/Gemfile
CHANGED
@@ -34,6 +34,12 @@ module ActiveRecord
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
+
class IBM_DBAdapter < AbstractAdapter
|
38
|
+
def truncate_table(table_name)
|
39
|
+
execute("TRUNCATE #{quote_table_name(table_name)} IMMEDIATE")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
37
43
|
class SQLite3Adapter < SQLITE_ADAPTER_PARENT
|
38
44
|
def delete_table(table_name)
|
39
45
|
execute("DELETE FROM #{quote_table_name(table_name)};")
|
@@ -72,7 +78,11 @@ module ActiveRecord
|
|
72
78
|
|
73
79
|
class SQLServerAdapter < AbstractAdapter
|
74
80
|
def truncate_table(table_name)
|
75
|
-
|
81
|
+
begin
|
82
|
+
execute("TRUNCATE TABLE #{quote_table_name(table_name)};")
|
83
|
+
rescue ActiveRecord::StatementInvalid
|
84
|
+
execute("DELETE FROM #{quote_table_name(table_name)};")
|
85
|
+
end
|
76
86
|
end
|
77
87
|
end
|
78
88
|
|
@@ -1,22 +1,17 @@
|
|
1
1
|
module DatabaseCleaner
|
2
2
|
module Mongo
|
3
3
|
module Truncation
|
4
|
-
|
4
|
+
|
5
5
|
def clean
|
6
6
|
if @only
|
7
|
-
collections.each { |c| remove
|
7
|
+
collections.each { |c| c.remove if @only.include?(c.name) }
|
8
8
|
else
|
9
|
-
collections.each { |c| remove
|
9
|
+
collections.each { |c| c.remove unless @tables_to_exclude.include?(c.name) }
|
10
10
|
end
|
11
11
|
true
|
12
12
|
end
|
13
13
|
|
14
14
|
private
|
15
|
-
|
16
|
-
def remove(collection)
|
17
|
-
collection.drop_indexes
|
18
|
-
collection.remove
|
19
|
-
end
|
20
15
|
|
21
16
|
def collections
|
22
17
|
database.collections.select { |c| c.name !~ /^system/ }
|
@@ -5,8 +5,11 @@ require 'database_cleaner/active_record/truncation'
|
|
5
5
|
|
6
6
|
module ActiveRecord
|
7
7
|
module ConnectionAdapters
|
8
|
-
[MysqlAdapter, Mysql2Adapter, SQLite3Adapter, JdbcAdapter, PostgreSQLAdapter].each do |adapter|
|
8
|
+
[MysqlAdapter, Mysql2Adapter, SQLite3Adapter, JdbcAdapter, PostgreSQLAdapter, IBM_DBAdapter].each do |adapter|
|
9
9
|
describe adapter, "#truncate_table" do
|
10
|
+
it "responds" do
|
11
|
+
adapter.new("foo").should respond_to(:truncate_table)
|
12
|
+
end
|
10
13
|
it "should truncate the table"
|
11
14
|
end
|
12
15
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: database_cleaner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 3
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 6
|
9
|
-
-
|
10
|
-
version: 0.6.
|
9
|
+
- 2
|
10
|
+
version: 0.6.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ben Mabey
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-02-04 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -38,13 +38,7 @@ files:
|
|
38
38
|
- cucumber.yml
|
39
39
|
- examples/Gemfile
|
40
40
|
- examples/Gemfile.lock
|
41
|
-
- examples/config/database.yml
|
42
41
|
- examples/config/database.yml.example
|
43
|
-
- examples/db/activerecord_one.db
|
44
|
-
- examples/db/activerecord_two.db
|
45
|
-
- examples/db/datamapper_default.db
|
46
|
-
- examples/db/datamapper_one.db
|
47
|
-
- examples/db/datamapper_two.db
|
48
42
|
- examples/db/sqlite_databases_go_here
|
49
43
|
- examples/features/example.feature
|
50
44
|
- examples/features/example_multiple_db.feature
|
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
two:
|
3
|
-
adapter: sqlite3
|
4
|
-
database: /Users/bmabey/Programming/ruby/database_cleaner/examples/features/support/../../db/activerecord_two.db
|
5
|
-
one:
|
6
|
-
adapter: sqlite3
|
7
|
-
database: /Users/bmabey/Programming/ruby/database_cleaner/examples/features/support/../../db/activerecord_one.db
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|