Skip to content

Commit

Permalink
Support rails 7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
maths22 committed Oct 4, 2023
1 parent 9a8d709 commit c8d1169
Show file tree
Hide file tree
Showing 9 changed files with 222 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
fail-fast: false
matrix:
ruby-version: [2.7, "3.0", 3.1, 3.2]
lockfile: ['Gemfile.rails-7.0.lock']
lockfile: ['Gemfile.rails-7.0.lock', 'Gemfile.rails-7.1.lock']

services:
postgres:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
/pkg/
/workflow/
/vendor/
/tmp/
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ AllCops:
Exclude:
- 'gemfiles/*'

Bundler/DuplicatedGem:
Enabled: false

Style/DocumentDynamicEvalDefinition:
Enabled: false

Expand Down
6 changes: 6 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,10 @@ gemspec

lockfile "rails-7.0", default: true do
gem "activerecord", "~> 7.0.0"
gem "railties", "~> 7.0.0"
end

lockfile "rails-7.1" do
gem "activerecord", "~> 7.1.0.rc2"
gem "railties", "~> 7.1.0.rc2"
end
196 changes: 196 additions & 0 deletions Gemfile.rails-7.1.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
PATH
remote: .
specs:
activerecord-pg-extensions (0.5.4)
activerecord (>= 7.0, < 7.2)
railties (>= 7.0, < 7.2)

GEM
remote: https://rubygems.org/
specs:
actionpack (7.1.0.rc2)
actionview (= 7.1.0.rc2)
activesupport (= 7.1.0.rc2)
nokogiri (>= 1.8.5)
rack (>= 2.2.4)
rack-session (>= 1.0.1)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
actionview (7.1.0.rc2)
activesupport (= 7.1.0.rc2)
builder (~> 3.1)
erubi (~> 1.11)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
activemodel (7.1.0.rc2)
activesupport (= 7.1.0.rc2)
activerecord (7.1.0.rc2)
activemodel (= 7.1.0.rc2)
activesupport (= 7.1.0.rc2)
timeout (>= 0.4.0)
activesupport (7.1.0.rc2)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
minitest (>= 5.1)
mutex_m
tzinfo (~> 2.0)
appraisal (2.5.0)
bundler
rake
thor (>= 0.14.0)
ast (2.4.2)
base64 (0.1.1)
bigdecimal (3.1.4)
builder (3.2.4)
concurrent-ruby (1.2.2)
connection_pool (2.4.1)
crass (1.0.6)
debug (1.8.0)
irb (>= 1.5.0)
reline (>= 0.3.1)
diff-lcs (1.5.0)
drb (2.1.1)
ruby2_keywords
erubi (1.12.0)
i18n (1.14.1)
concurrent-ruby (~> 1.0)
io-console (0.6.0)
irb (1.8.1)
rdoc
reline (>= 0.3.8)
json (2.6.3)
language_server-protocol (3.17.0.3)
loofah (2.21.3)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
mini_portile2 (2.8.4)
minitest (5.20.0)
mutex_m (0.1.2)
nokogiri (1.15.4)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
nokogiri (1.15.4-arm64-darwin)
racc (~> 1.4)
nokogiri (1.15.4-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.15.4-x86_64-linux)
racc (~> 1.4)
parallel (1.23.0)
parser (3.2.2.3)
ast (~> 2.4.1)
racc
pg (1.5.4)
psych (5.1.0)
stringio
racc (1.7.1)
rack (3.0.8)
rack-session (2.0.0)
rack (>= 3.0.0)
rack-test (2.1.0)
rack (>= 1.3)
rackup (2.1.0)
rack (>= 3)
webrick (~> 1.8)
rails-dom-testing (2.2.0)
activesupport (>= 5.0.0)
minitest
nokogiri (>= 1.6)
rails-html-sanitizer (1.6.0)
loofah (~> 2.21)
nokogiri (~> 1.14)
railties (7.1.0.rc2)
actionpack (= 7.1.0.rc2)
activesupport (= 7.1.0.rc2)
irb
rackup (>= 1.0.0)
rake (>= 12.2)
thor (~> 1.0, >= 1.2.2)
zeitwerk (~> 2.6)
rainbow (3.1.1)
rake (13.0.6)
rdoc (6.5.0)
psych (>= 4.0.0)
regexp_parser (2.8.1)
reline (0.3.9)
io-console (~> 0.5)
rexml (3.2.6)
rspec (3.12.0)
rspec-core (~> 3.12.0)
rspec-expectations (~> 3.12.0)
rspec-mocks (~> 3.12.0)
rspec-core (3.12.2)
rspec-support (~> 3.12.0)
rspec-expectations (3.12.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-mocks (3.12.6)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-support (3.12.1)
rubocop (1.56.2)
base64 (~> 0.1.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.2.2.3)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.28.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.29.0)
parser (>= 3.2.1.0)
rubocop-capybara (2.18.0)
rubocop (~> 1.41)
rubocop-factory_bot (2.23.1)
rubocop (~> 1.33)
rubocop-inst (1.0.2)
rubocop (~> 1.50)
rubocop-performance (~> 1.17)
rubocop-performance (1.19.0)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
rubocop-rake (0.6.0)
rubocop (~> 1.0)
rubocop-rspec (2.23.2)
rubocop (~> 1.33)
rubocop-capybara (~> 2.17)
rubocop-factory_bot (~> 2.22)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
stringio (3.0.8)
thor (1.2.2)
timeout (0.4.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.4.2)
webrick (1.8.1)
zeitwerk (2.6.12)

PLATFORMS
arm64-darwin
ruby
x86_64-darwin
x86_64-linux

DEPENDENCIES
activerecord (~> 7.1.0.rc2)
activerecord-pg-extensions!
appraisal (~> 2.4)
debug (~> 1.8)
pg (~> 1.2)
railties (~> 7.1.0.rc2)
rake (~> 13.0)
rspec (~> 3.0)
rubocop-inst (~> 1)
rubocop-rake (~> 0.5)
rubocop-rspec (~> 2.3)

BUNDLED WITH
2.4.19
4 changes: 2 additions & 2 deletions activerecord-pg-extensions.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ Gem::Specification.new do |spec|
spec.files = Dir["lib/**/*"] + ["LICENSE.txt", "README.md", "CHANGELOG.md"]
spec.require_paths = ["lib"]

spec.add_dependency "activerecord", "~> 7.0.0"
spec.add_dependency "railties", "~> 7.0.0"
spec.add_dependency "activerecord", ">= 7.0", "< 7.2"
spec.add_dependency "railties", ">= 7.0", "< 7.2"

spec.add_development_dependency "appraisal", "~> 2.4"
spec.add_development_dependency "debug", "~> 1.8"
Expand Down
3 changes: 3 additions & 0 deletions lib/active_record/pg_extensions/transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ def #{kind}(local: false)
return if @#{kind} == timeout
@#{kind} = timeout
# If we have set an explicit timeout, the transaction has state that must be materialized
# separately from any other transaction, so it cannot be `restartable`
dirty! unless ::Rails.version < '7.1'
return unless materialized?
connection.set(#{kind.inspect}, "\#{(timeout * 1000).to_i}ms", local: true)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/active_record/pg_extensions/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

module ActiveRecord
module PGExtensions
VERSION = "0.5.3"
VERSION = "0.5.4"
end
end
12 changes: 9 additions & 3 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Application < Rails::Application
end
Application.initialize!

ActiveRecord::Tasks::DatabaseTasks.create_all
ActiveRecord::Tasks::DatabaseTasks.create_current

module StatementCaptureConnection
def dont_execute
Expand All @@ -28,7 +28,12 @@ def executed_statements
@executed_statements ||= []
end

%w[execute exec_no_cache exec_cache].each do |method|
methods = if Rails.version < "7.1"
%w[execute exec_no_cache exec_cache]
else
%w[internal_execute exec_no_cache exec_cache]
end
methods.each do |method|
class_eval <<-RUBY, __FILE__, __LINE__ + 1
def #{method}(statement, *, **)
materialize_transactions # this still needs to get called, even if we skip actually executing
Expand All @@ -43,7 +48,8 @@ def #{method}(statement, *, **)
# we can't actually generate a dummy one of these, so we just query the db with something
# that won't return anything
def empty_pg_result
@connection.async_exec("SELECT 0 WHERE FALSE")
conn = (::Rails.version < "7.1") ? @connection : @raw_connection
conn.async_exec("SELECT 0 WHERE FALSE")
end
end
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.prepend(StatementCaptureConnection)
Expand Down

0 comments on commit c8d1169

Please sign in to comment.