activerecord-forbid_implicit_connection_checkout 3.0.0 → 4.0.0

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: 7911932062c41fe886289b67f7fd4c26fdded670c2e7a1c22d7e00fe3f2c6f8a
4
- data.tar.gz: 78283dcfa6ab739ceb9a02396b860403565ddd9bb497b12c98a6b5dc4a411290
3
+ metadata.gz: 98156e29b5ba84d71e4ee41f9d8d6e8c8536bc338dfdcd6caae958b26e2cfd26
4
+ data.tar.gz: e94ec07031972ef9126a73878f8544cb488c75d917678667a31e11139f0bb289
5
5
  SHA512:
6
- metadata.gz: c8f34e3e76e7a2b8171107ee3a34c8e83271b3fc2fa4c368644252f5a01577c4e975e16f1088d9d421692ecf3d71cb303cd3220456f66a4dc39aaadfc835e03b
7
- data.tar.gz: cf9ace624ca0983ce860b092f62e721ceff3782bd8669dbed07a1718f379cb09c0a17cbd9a9a41ac4041f363d1454c19aaff5ae11fe4da45499cab18a2296947
6
+ metadata.gz: ab7d286ea151948f49ca420643baa22c0317717a0fca52ae7778eb68a8639d1315f57733270c7dd7e939016c6fd50d3afd6404b9caf6829d94a4f71dfa45f583
7
+ data.tar.gz: 18e44aa315538e14ea1d04587b17bf93be9bc3018e958d713223d3a4485a7d8220e06aa69d3b7a0991bd1d78e79c8ebdc17a6beac021bd8637da43893b90e0e0
data/.circleci/config.yml CHANGED
@@ -2,23 +2,24 @@ version: 2.1
2
2
  jobs:
3
3
  lint:
4
4
  docker:
5
- - image: cimg/ruby:3.1.6
5
+ - image: cimg/ruby:3.3.11
6
6
  working_directory: ~/activerecord-forbid_implicit_connection_checkout
7
7
  steps:
8
8
  - checkout
9
9
  - restore_cache:
10
10
  keys:
11
- - v1-gems-ruby-3.1.6-{{ checksum "activerecord-forbid_implicit_connection_checkout.gemspec" }}-{{ checksum "Gemfile" }}
12
- - v1-gems-ruby-3.1.6-
11
+ - v1-gems-ruby-3.3.11-{{ checksum "activerecord-forbid_implicit_connection_checkout.gemspec" }}-{{ checksum "Gemfile" }}
12
+ - v1-gems-ruby-3.3.11-
13
13
  - run:
14
14
  name: Install Gems
15
15
  command: |
16
- if ! bundle check --path=vendor/bundle; then
17
- bundle install --path=vendor/bundle --jobs=4 --retry=3
16
+ bundle config set path 'vendor/bundle'
17
+ if ! bundle check; then
18
+ bundle install --jobs=4 --retry=3
18
19
  bundle clean
19
20
  fi
20
21
  - save_cache:
21
- key: v1-gems-ruby-3.1.6-{{ checksum "activerecord-forbid_implicit_connection_checkout.gemspec" }}-{{ checksum "Gemfile" }}
22
+ key: v1-gems-ruby-3.3.11-{{ checksum "activerecord-forbid_implicit_connection_checkout.gemspec" }}-{{ checksum "Gemfile" }}
22
23
  paths:
23
24
  - "vendor/bundle"
24
25
  - "gemfiles/vendor/bundle"
@@ -53,8 +54,9 @@ jobs:
53
54
  - run:
54
55
  name: Install Gems
55
56
  command: |
56
- if ! bundle check --path=vendor/bundle; then
57
- bundle install --path=vendor/bundle --jobs=4 --retry=3
57
+ bundle config set path 'vendor/bundle'
58
+ if ! bundle check; then
59
+ bundle install --jobs=4 --retry=3
58
60
  bundle clean
59
61
  fi
60
62
  - save_cache:
@@ -82,17 +84,9 @@ workflows:
82
84
  matrix:
83
85
  parameters:
84
86
  gemfile:
85
- - gemfiles/rails_7.0.gemfile
86
- - gemfiles/rails_7.1.gemfile
87
- - gemfiles/rails_7.2.gemfile
88
87
  - gemfiles/rails_8.0.gemfile
88
+ - gemfiles/rails_8.1.gemfile
89
89
  ruby_version:
90
- - 3.1.6
91
- - 3.2.6
92
- - 3.3.6
93
- - 3.4.1
94
- exclude:
95
- - gemfile: gemfiles/rails_8.0.gemfile
96
- ruby_version: 3.1.6
97
- - gemfile: gemfiles/rails_7.0.gemfile
98
- ruby_version: 3.4.1
90
+ - 3.3.11
91
+ - 3.4.9
92
+ - 4.0.6
data/.rubocop.yml CHANGED
@@ -2,7 +2,7 @@ inherit_gem:
2
2
  salsify_rubocop: conf/rubocop.yml
3
3
 
4
4
  AllCops:
5
- TargetRubyVersion: 3.1
5
+ TargetRubyVersion: 3.3
6
6
  Exclude:
7
7
  - 'vendor/**/*'
8
8
  - 'gemfiles/**/*'
data/Appraisals CHANGED
@@ -1,17 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- appraise 'rails-7.0' do
4
- gem 'rails', '~> 7.0.8'
5
- end
6
-
7
- appraise 'rails-7.1' do
8
- gem 'rails', '~> 7.1.5'
9
- end
10
-
11
- appraise 'rails-7.2' do
12
- gem 'rails', '~> 7.2.2'
13
- end
14
-
15
3
  appraise 'rails-8.0' do
16
4
  gem 'rails', '~> 8.0.1'
17
5
  end
6
+
7
+ appraise 'rails-8.1' do
8
+ gem 'rails', '~> 8.1.0'
9
+ end
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # activerecord-forbid_implicit_checkout
2
2
 
3
+ ## v4.0.0
4
+ - Also forbid checkout via `lease_connection` and `with_connection`, the paths Active Record has
5
+ used for its own queries since Rails 7.2. Previously only `connection` was intercepted, so an
6
+ ordinary query in a forbidding thread checked out a connection silently.
7
+ - Drop support for Ruby 3.1, 3.2
8
+ - Drop support for Rails 7.0, 7.1, 7.2
9
+ - Add support for Ruby 4.0
10
+ - Add support for Rails 8.1
11
+
3
12
  ## v3.0.0
4
13
  - Drop support for Ruby 2.7, 3.0
5
14
  - Drop support for Rails 6.0, 6.1
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
16
16
 
17
17
  spec.license = 'MIT'
18
18
 
19
- spec.required_ruby_version = '>= 3.1'
19
+ spec.required_ruby_version = '>= 3.3'
20
20
 
21
21
  # Set 'allowed_push_post' to control where this gem can be published.
22
22
  if spec.respond_to?(:metadata)
@@ -31,9 +31,9 @@ Gem::Specification.new do |spec|
31
31
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
32
32
  spec.require_paths = ['lib']
33
33
 
34
- spec.add_dependency 'activemodel', '>= 7.0', '< 8.1'
35
- spec.add_dependency 'activerecord', '>= 7.0', '< 8.1'
36
- spec.add_dependency 'activesupport', '>= 7.0', '< 8.1'
34
+ spec.add_dependency 'activemodel', '>= 8.0', '< 8.2'
35
+ spec.add_dependency 'activerecord', '>= 8.0', '< 8.2'
36
+ spec.add_dependency 'activesupport', '>= 8.0', '< 8.2'
37
37
 
38
38
  spec.add_development_dependency 'appraisal'
39
39
  spec.add_development_dependency 'bundler'
@@ -43,6 +43,6 @@ Gem::Specification.new do |spec|
43
43
  spec.add_development_dependency 'rake', '~> 13.0'
44
44
  spec.add_development_dependency 'rspec', '~> 3.12'
45
45
  spec.add_development_dependency 'rspec_junit_formatter'
46
- spec.add_development_dependency 'salsify_rubocop', '~> 1.42.1'
46
+ spec.add_development_dependency 'salsify_rubocop', '~> 1.59.1'
47
47
  spec.add_development_dependency 'with_model'
48
48
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "rails", "~> 7.0.8"
5
+ gem "rails", "~> 8.1.0"
6
6
 
7
7
  gemspec path: "../"
@@ -5,14 +5,33 @@ require 'active_record/implicit_connection_forbidden_error'
5
5
  module ActiveRecord
6
6
  module ForbidImplicitConnectionCheckout
7
7
  module ConnectionOverride
8
- def connection(*args, &block)
9
- if Thread.current[:active_record_forbid_implicit_connections] &&
10
- !connection_handler.retrieve_connection_pool(connection_specification_name).active_connection?
11
- raise ActiveRecord::ImplicitConnectionForbiddenError.new
12
- end
8
+ def connection(...)
9
+ forbid_implicit_connection_checkout!
10
+ super
11
+ end
12
+
13
+ # Active Record leases connections for its own queries through the class level
14
+ # `lease_connection` and `with_connection`, so guarding `connection` alone never sees an
15
+ # ordinary query. The pool level `ConnectionPool#with_connection` and `#checkout` are
16
+ # deliberately left alone: they are the documented way for a thread to opt back in.
17
+ def lease_connection(...)
18
+ forbid_implicit_connection_checkout!
19
+ super
20
+ end
13
21
 
22
+ def with_connection(...)
23
+ forbid_implicit_connection_checkout!
14
24
  super
15
25
  end
26
+
27
+ private
28
+
29
+ def forbid_implicit_connection_checkout!
30
+ return unless Thread.current[:active_record_forbid_implicit_connections]
31
+ return if connection_handler.retrieve_connection_pool(connection_specification_name).active_connection?
32
+
33
+ raise ActiveRecord::ImplicitConnectionForbiddenError.new
34
+ end
16
35
  end
17
36
  end
18
37
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ActiveRecord
4
4
  module ForbidImplicitConnectionCheckout
5
- VERSION = '3.0.0'
5
+ VERSION = '4.0.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-forbid_implicit_connection_checkout
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Salsify, Inc
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-03-11 00:00:00.000000000 Z
11
+ date: 2026-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -16,60 +16,60 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '7.0'
19
+ version: '8.0'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '8.1'
22
+ version: '8.2'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: '7.0'
29
+ version: '8.0'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '8.1'
32
+ version: '8.2'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: activerecord
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: '7.0'
39
+ version: '8.0'
40
40
  - - "<"
41
41
  - !ruby/object:Gem::Version
42
- version: '8.1'
42
+ version: '8.2'
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
46
46
  requirements:
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: '7.0'
49
+ version: '8.0'
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
- version: '8.1'
52
+ version: '8.2'
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: activesupport
55
55
  requirement: !ruby/object:Gem::Requirement
56
56
  requirements:
57
57
  - - ">="
58
58
  - !ruby/object:Gem::Version
59
- version: '7.0'
59
+ version: '8.0'
60
60
  - - "<"
61
61
  - !ruby/object:Gem::Version
62
- version: '8.1'
62
+ version: '8.2'
63
63
  type: :runtime
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - ">="
68
68
  - !ruby/object:Gem::Version
69
- version: '7.0'
69
+ version: '8.0'
70
70
  - - "<"
71
71
  - !ruby/object:Gem::Version
72
- version: '8.1'
72
+ version: '8.2'
73
73
  - !ruby/object:Gem::Dependency
74
74
  name: appraisal
75
75
  requirement: !ruby/object:Gem::Requirement
@@ -188,14 +188,14 @@ dependencies:
188
188
  requirements:
189
189
  - - "~>"
190
190
  - !ruby/object:Gem::Version
191
- version: 1.42.1
191
+ version: 1.59.1
192
192
  type: :development
193
193
  prerelease: false
194
194
  version_requirements: !ruby/object:Gem::Requirement
195
195
  requirements:
196
196
  - - "~>"
197
197
  - !ruby/object:Gem::Version
198
- version: 1.42.1
198
+ version: 1.59.1
199
199
  - !ruby/object:Gem::Dependency
200
200
  name: with_model
201
201
  requirement: !ruby/object:Gem::Requirement
@@ -235,10 +235,8 @@ files:
235
235
  - bin/console
236
236
  - bin/setup
237
237
  - gemfiles/.bundle/config
238
- - gemfiles/rails_7.0.gemfile
239
- - gemfiles/rails_7.1.gemfile
240
- - gemfiles/rails_7.2.gemfile
241
238
  - gemfiles/rails_8.0.gemfile
239
+ - gemfiles/rails_8.1.gemfile
242
240
  - lib/active_record-forbid_implicit_connection_checkout.rb
243
241
  - lib/active_record/forbid_implicit_connection_checkout/connection_override.rb
244
242
  - lib/active_record/forbid_implicit_connection_checkout/prevent_connection_checkout.rb
@@ -250,7 +248,7 @@ licenses:
250
248
  metadata:
251
249
  allowed_push_host: https://rubygems.org
252
250
  rubygems_mfa_required: 'true'
253
- post_install_message:
251
+ post_install_message:
254
252
  rdoc_options: []
255
253
  require_paths:
256
254
  - lib
@@ -258,15 +256,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
258
256
  requirements:
259
257
  - - ">="
260
258
  - !ruby/object:Gem::Version
261
- version: '3.1'
259
+ version: '3.3'
262
260
  required_rubygems_version: !ruby/object:Gem::Requirement
263
261
  requirements:
264
262
  - - ">="
265
263
  - !ruby/object:Gem::Version
266
264
  version: '0'
267
265
  requirements: []
268
- rubygems_version: 3.3.26
269
- signing_key:
266
+ rubygems_version: 3.5.22
267
+ signing_key:
270
268
  specification_version: 4
271
269
  summary: Optionally prevents threads from checking out activerecord connections.
272
270
  test_files: []
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 7.1.5"
6
-
7
- gemspec path: "../"
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 7.2.2"
6
-
7
- gemspec path: "../"