database_rewinder 0.9.9 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 395cf45a9155494fbaa28f887a793d3780c6c4dea757e53d9c9057ddec96baca
4
- data.tar.gz: 68088ac4f44554359f87e946db585812301557287c5f3b63b88c1c45b29f865d
3
+ metadata.gz: 70ee7b28c9d9290e07433937617945e672286d2f3c0cf3a5c535382fd5d3a99d
4
+ data.tar.gz: 901710b74fe84c132971024b4801c7cb317a50ae04afac23e04e29a78ad56f39
5
5
  SHA512:
6
- metadata.gz: 80e0acaed09f0606b8ae715e072c9d9198c97fcd07cedbda94c1442ef256970e89da10a983935724440fb98362210bf986f800051b79223c828061828e563b68
7
- data.tar.gz: d0c1275d8ee0a691271a5569c499f1c23c98167089935161b798090d84b1136039ca4c7d9b34186688d48671c821b18a754614c3fc2683b93907ffdf92bbdd4d
6
+ metadata.gz: 36ca3e961e9d5d169741af157affe54e64b294acbb9cd4ed853f6dd359ac3c94d18455dc5a98c9f94470f72a04c12e17fc5c53369257114cd4f73e8d809ee9cb
7
+ data.tar.gz: bff027775582aa76c58ae5cac1a6ff505e950e1feb39b26185a4aa43c6774955da38549d40e01fdabb4018fb81e19c3b85ace3a0eb81658f385ca2f53b9fcd3c
@@ -27,39 +27,71 @@ jobs:
27
27
 
28
28
  matrix:
29
29
  db: [sqlite3, postgresql, mysql]
30
- ruby_version: [ruby-head, '3.2', '3.1', '3.0', '2.7', '2.6']
30
+ ruby_version: [ruby-head, '3.3', '3.2', '3.1']
31
31
  rails_version: [edge, '7.1', '7.0', '6.1']
32
32
 
33
33
  exclude:
34
- - ruby_version: '2.6'
35
- rails_version: edge
36
-
37
- - ruby_version: '2.6'
38
- rails_version: '7.1'
39
-
40
- - ruby_version: '2.6'
41
- rails_version: '7.0'
42
-
43
34
  - ruby_version: ruby-head
44
35
  rails_version: '6.1'
45
36
 
46
37
  include:
38
+ - ruby_version: '3.0'
39
+ rails_version: '7.1'
40
+ db: sqlite3
41
+ - ruby_version: '3.0'
42
+ rails_version: '7.1'
43
+ db: postgresql
44
+ - ruby_version: '3.0'
45
+ rails_version: '7.1'
46
+ db: mysql
47
+
47
48
  - ruby_version: '2.7'
48
- rails_version: '6.0'
49
+ rails_version: '7.1'
49
50
  db: sqlite3
50
51
  - ruby_version: '2.7'
51
- rails_version: '6.0'
52
+ rails_version: '7.1'
52
53
  db: postgresql
53
54
  - ruby_version: '2.7'
54
- rails_version: '6.0'
55
+ rails_version: '7.1'
55
56
  db: mysql
57
+
58
+ - ruby_version: '2.7'
59
+ rails_version: '7.0'
60
+ db: sqlite3
61
+ - ruby_version: '2.7'
62
+ rails_version: '7.0'
63
+ db: postgresql
64
+ - ruby_version: '2.7'
65
+ rails_version: '7.0'
66
+ db: mysql
67
+
68
+ - ruby_version: '3.0'
69
+ rails_version: '6.1'
70
+ db: sqlite3
71
+ - ruby_version: '3.0'
72
+ rails_version: '6.1'
73
+ db: postgresql
74
+ - ruby_version: '3.0'
75
+ rails_version: '6.1'
76
+ db: mysql
77
+
56
78
  - ruby_version: '2.6'
57
- rails_version: '6.0'
79
+ rails_version: '6.1'
58
80
  db: sqlite3
59
81
  - ruby_version: '2.6'
60
- rails_version: '6.0'
82
+ rails_version: '6.1'
61
83
  db: postgresql
62
84
  - ruby_version: '2.6'
85
+ rails_version: '6.1'
86
+ db: mysql
87
+
88
+ - ruby_version: '2.7'
89
+ rails_version: '6.0'
90
+ db: sqlite3
91
+ - ruby_version: '2.7'
92
+ rails_version: '6.0'
93
+ db: postgresql
94
+ - ruby_version: '2.7'
63
95
  rails_version: '6.0'
64
96
  db: mysql
65
97
 
@@ -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 = '0.9.9'
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) { (@raw_connection || @connection).exec sql } }
19
+ disable_referential_integrity { log(sql) { raw_connection_or_connection.exec sql } }
16
20
  when 'ActiveRecord::ConnectionAdapters::Mysql2Adapter'
17
- if (@raw_connection || @connection).query_options[:connect_flags] & Mysql2::Client::MULTI_STATEMENTS != 0
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) { (@raw_connection || @connection).query sql }
20
- while (@raw_connection || @connection).next_result
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 = (@raw_connection || @connection).store_result
26
+ _result = raw_connection_or_connection.store_result
23
27
  end
24
28
  end
25
29
  else
26
- query_options = (@raw_connection || @connection).query_options.dup
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) { (@raw_connection || @connection).execute_batch 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
@@ -22,6 +22,8 @@ module DatabaseRewinder
22
22
  end
23
23
 
24
24
  def [](connection)
25
+ init unless defined? @cleaners
26
+
25
27
  @cleaners.detect {|c| c.connection_name == connection} || create_cleaner(connection)
26
28
  end
27
29
 
@@ -75,7 +77,12 @@ module DatabaseRewinder
75
77
  def all_table_names(connection)
76
78
  cache_key = get_cache_key(connection.pool)
77
79
  #NOTE connection.tables warns on AR 5 with some adapters
78
- tables = ActiveSupport::Deprecation.silence { connection.tables }
80
+ tables =
81
+ if ActiveRecord::VERSION::MAJOR == 5 && ActiveRecord::VERSION::MINOR == 0
82
+ ActiveSupport::Deprecation.silence { connection.tables }
83
+ else
84
+ connection.tables
85
+ end
79
86
  schema_migraion_table_name =
80
87
  if ActiveRecord::SchemaMigration.respond_to?(:table_name)
81
88
  ActiveRecord::SchemaMigration.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: 0.9.9
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: 2023-11-15 00:00:00.000000000 Z
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
@@ -113,8 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
111
  - !ruby/object:Gem::Version
114
112
  version: '0'
115
113
  requirements: []
116
- rubygems_version: 3.5.0.dev
117
- signing_key:
114
+ rubygems_version: 3.6.0.dev
118
115
  specification_version: 4
119
116
  summary: A minimalist's tiny and ultra-fast database cleaner
120
117
  test_files: