database_rewinder 1.0.0 → 1.0.1
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.
- checksums.yaml +4 -4
- data/database_rewinder.gemspec +1 -1
- data/lib/database_rewinder/multiple_statements_executor.rb +11 -7
- data/lib/database_rewinder.rb +3 -3
- metadata +2 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70ee7b28c9d9290e07433937617945e672286d2f3c0cf3a5c535382fd5d3a99d
|
4
|
+
data.tar.gz: 901710b74fe84c132971024b4801c7cb317a50ae04afac23e04e29a78ad56f39
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36ca3e961e9d5d169741af157affe54e64b294acbb9cd4ed853f6dd359ac3c94d18455dc5a98c9f94470f72a04c12e17fc5c53369257114cd4f73e8d809ee9cb
|
7
|
+
data.tar.gz: bff027775582aa76c58ae5cac1a6ff505e950e1feb39b26185a4aa43c6774955da38549d40e01fdabb4018fb81e19c3b85ace3a0eb81658f385ca2f53b9fcd3c
|
data/database_rewinder.gemspec
CHANGED
@@ -6,7 +6,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
6
6
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
8
|
spec.name = "database_rewinder"
|
9
|
-
spec.version = '1.0.
|
9
|
+
spec.version = '1.0.1'
|
10
10
|
spec.authors = ["Akira Matsuda"]
|
11
11
|
spec.email = ["ronnie@dio.jp"]
|
12
12
|
spec.description = "A minimalist's tiny and ultra-fast database cleaner for Active Record"
|
@@ -8,22 +8,26 @@ module DatabaseRewinder
|
|
8
8
|
%w(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter ActiveRecord::ConnectionAdapters::Mysql2Adapter ActiveRecord::ConnectionAdapters::SQLite3Adapter).include? self.class.name
|
9
9
|
end
|
10
10
|
|
11
|
+
def raw_connection_or_connection
|
12
|
+
defined?(@raw_connection) ? @raw_connection : @connection
|
13
|
+
end
|
14
|
+
|
11
15
|
def execute_multiple(sql)
|
12
16
|
#TODO Use ADAPTER_NAME when we've dropped AR 4.1 support
|
13
17
|
case self.class.name
|
14
18
|
when 'ActiveRecord::ConnectionAdapters::PostgreSQLAdapter'
|
15
|
-
disable_referential_integrity { log(sql) {
|
19
|
+
disable_referential_integrity { log(sql) { raw_connection_or_connection.exec sql } }
|
16
20
|
when 'ActiveRecord::ConnectionAdapters::Mysql2Adapter'
|
17
|
-
if
|
21
|
+
if raw_connection_or_connection.query_options[:connect_flags] & Mysql2::Client::MULTI_STATEMENTS != 0
|
18
22
|
disable_referential_integrity do
|
19
|
-
_result = log(sql) {
|
20
|
-
while
|
23
|
+
_result = log(sql) { raw_connection_or_connection.query sql }
|
24
|
+
while raw_connection_or_connection.next_result
|
21
25
|
# just to make sure that all queries are finished
|
22
|
-
_result =
|
26
|
+
_result = raw_connection_or_connection.store_result
|
23
27
|
end
|
24
28
|
end
|
25
29
|
else
|
26
|
-
query_options =
|
30
|
+
query_options = raw_connection_or_connection.query_options.dup
|
27
31
|
query_options[:connect_flags] |= Mysql2::Client::MULTI_STATEMENTS
|
28
32
|
# opens another connection to the DB
|
29
33
|
client = Mysql2::Client.new query_options
|
@@ -40,7 +44,7 @@ module DatabaseRewinder
|
|
40
44
|
end
|
41
45
|
end
|
42
46
|
when 'ActiveRecord::ConnectionAdapters::SQLite3Adapter'
|
43
|
-
disable_referential_integrity { log(sql) {
|
47
|
+
disable_referential_integrity { log(sql) { raw_connection_or_connection.execute_batch sql } }
|
44
48
|
else
|
45
49
|
raise 'Multiple deletion is not supported with the current database adapter.'
|
46
50
|
end
|
data/lib/database_rewinder.rb
CHANGED
@@ -78,10 +78,10 @@ module DatabaseRewinder
|
|
78
78
|
cache_key = get_cache_key(connection.pool)
|
79
79
|
#NOTE connection.tables warns on AR 5 with some adapters
|
80
80
|
tables =
|
81
|
-
if
|
82
|
-
Rails.application.deprecators.silence { connection.tables }
|
83
|
-
else
|
81
|
+
if ActiveRecord::VERSION::MAJOR == 5 && ActiveRecord::VERSION::MINOR == 0
|
84
82
|
ActiveSupport::Deprecation.silence { connection.tables }
|
83
|
+
else
|
84
|
+
connection.tables
|
85
85
|
end
|
86
86
|
schema_migraion_table_name =
|
87
87
|
if ActiveRecord::SchemaMigration.respond_to?(:table_name)
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: database_rewinder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Akira Matsuda
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date: 2024-
|
10
|
+
date: 2024-02-27 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: bundler
|
@@ -98,7 +97,6 @@ homepage: https://github.com/amatsuda/database_rewinder
|
|
98
97
|
licenses:
|
99
98
|
- MIT
|
100
99
|
metadata: {}
|
101
|
-
post_install_message:
|
102
100
|
rdoc_options: []
|
103
101
|
require_paths:
|
104
102
|
- lib
|
@@ -114,7 +112,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
112
|
version: '0'
|
115
113
|
requirements: []
|
116
114
|
rubygems_version: 3.6.0.dev
|
117
|
-
signing_key:
|
118
115
|
specification_version: 4
|
119
116
|
summary: A minimalist's tiny and ultra-fast database cleaner
|
120
117
|
test_files:
|