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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fba90991ea75253ed37624e82b4f6c26ae379f4c3b1d24a522192befb8529757
4
- data.tar.gz: 70c3c776b0e291b49a873e503f4111cb537e9685479176527cd94de9a663cff2
3
+ metadata.gz: 70ee7b28c9d9290e07433937617945e672286d2f3c0cf3a5c535382fd5d3a99d
4
+ data.tar.gz: 901710b74fe84c132971024b4801c7cb317a50ae04afac23e04e29a78ad56f39
5
5
  SHA512:
6
- metadata.gz: 457ed185619931c3aba3c9dd0b1a03b2156e712bfae655300d737bb1ac54ccc86a2d0256878ca7e765a2bd55e8798f6a855a9420eb5c2b8123cbd68b1298646b
7
- data.tar.gz: ad40ddaa9b69d852a3001d60c6673dcd335a4171c7c77d05245b94f0c022a71a33bef1c323d7ddc6c1297498ea18ad52037ea78f8c17335a15d7a280fcf378a8
6
+ metadata.gz: 36ca3e961e9d5d169741af157affe54e64b294acbb9cd4ed853f6dd359ac3c94d18455dc5a98c9f94470f72a04c12e17fc5c53369257114cd4f73e8d809ee9cb
7
+ data.tar.gz: bff027775582aa76c58ae5cac1a6ff505e950e1feb39b26185a4aa43c6774955da38549d40e01fdabb4018fb81e19c3b85ace3a0eb81658f385ca2f53b9fcd3c
@@ -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.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) { (@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
@@ -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 Rails.application.respond_to?(:deprecators) # AR >= 7.1
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.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-01-09 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
@@ -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: