Skip to content

Commit dc07f0e

Browse files
authored
Merge pull request #42 from amygurski/fix_rails_6_1
Support Rails 6.1
2 parents bbbae05 + 360c7f2 commit dc07f0e

File tree

5 files changed

+17
-10
lines changed

5 files changed

+17
-10
lines changed

History.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
3.0.0 / 2021-05-12
2+
==================
3+
4+
* Changes to support Rails 6.1.
5+
* Fetch config for database name differently because rails removed the connection_id key from the sql.active_record notification.
16

27
1.0.0 / 2016-05-04
38
==================

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,20 @@ before do
6060
end
6161
```
6262

63-
Or if you're using FactoryGirl you could do something like this:
63+
Or if you're using FactoryBot you could do something like this:
6464
```ruby
6565
RSpec.configure do |config|
66-
module FactoryBoy
66+
module FactoryKid
6767
def create(*args)
68-
SqlFootprint.exclude { FactoryGirl.create(*args) }
68+
SqlFootprint.exclude { FactoryBot.create(*args) }
6969
end
7070
end
71-
config.include FactoryBoy
71+
config.include FactoryKid
7272
end
7373
```
7474

75+
## Compatibility
76+
- For Rails < 6.0 compatibility, please use v2.0.1.
77+
- For Rails >= 6.0 compatibility, please use v3.0.0.
78+
7579
DO NOT run SqlFootprint in production!

lib/sql_footprint.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
module SqlFootprint
99
ActiveSupport::Notifications.subscribe('sql.active_record') do |_, _, _, _, payload|
1010
if @capture
11-
adapter = ObjectSpace._id2ref(payload.fetch(:connection_id))
12-
config = adapter.instance_variable_get(:@config) ||
13-
adapter.instance_variable_get(:@connection_options)
11+
config = payload.fetch(:connection).instance_variable_get(:@config)
1412
database_name = config.fetch(:database)
1513
capturers[database_name].capture payload.fetch(:sql)
1614
end

lib/sql_footprint/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module SqlFootprint
2-
VERSION = '2.0.1'.freeze
2+
VERSION = '3.0.0'.freeze
33
end

sql_footprint.gemspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ Gem::Specification.new do |spec|
2424
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
2525
spec.require_paths = ['lib']
2626

27-
spec.add_dependency 'activerecord', ['>= 3.0']
28-
spec.add_dependency 'activesupport', ['>= 3.0']
27+
spec.add_dependency 'activerecord', ['>= 6.0', '< 7.0']
28+
spec.add_dependency 'activesupport', ['>= 6.0', '< 7.0']
2929

3030
spec.add_development_dependency 'bundler', ['>= 1.7', '< 3.0']
3131
spec.add_development_dependency 'rake', '~> 10.0'

0 commit comments

Comments
 (0)