Skip to content

Commit

Permalink
Merge pull request #29 from grosser/nony--rails-7-1
Browse files Browse the repository at this point in the history
Test with Ruby 3.2 & 3.3, add support for Rails 7.1, release v0.8.0
  • Loading branch information
grosser authored Jan 16, 2024
2 parents 48b3dec + 86ad76d commit 70ca910
Show file tree
Hide file tree
Showing 12 changed files with 127 additions and 21 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,17 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: ['2.7', '3.0', '3.1']
activerecord: ['5.2', '6.0', '6.1', '7.0']
ruby: ['2.7', '3.0', '3.1', '3.2', '3.3']
activerecord: ['5.2', '6.0', '6.1', '7.0', '7.1']
exclude:
- ruby: '3.0'
activerecord: '5.2'
- ruby: '3.1'
activerecord: '5.2'
- ruby: '3.2'
activerecord: '5.2'
- ruby: '3.3'
activerecord: '5.2'
name: ruby${{ matrix.ruby }} activerecord${{ matrix.activerecord }}
env:
BUNDLE_GEMFILE: gemfiles/activerecord_${{ matrix.activerecord }}.gemfile
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
PATH
remote: .
specs:
active_record-comments (0.7.0)
activerecord (>= 5, < 7.1)
active_record-comments (0.8.0)
activerecord (>= 5, < 7.2)

GEM
remote: https://rubygems.org/
Expand Down
2 changes: 1 addition & 1 deletion active_record-comments.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ Gem::Specification.new do |s|
s.homepage = "https://github.com/grosser/active_record-comments"
s.files = `git ls-files lib/ MIT-LICENSE`.split("\n")
s.license = "MIT"
s.add_runtime_dependency "activerecord", ">= 5", "< 7.1"
s.add_runtime_dependency "activerecord", ">= 5", "< 7.2"
s.required_ruby_version = '>= 2.7'
end
4 changes: 2 additions & 2 deletions gemfiles/activerecord_5.2.gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
PATH
remote: ..
specs:
active_record-comments (0.7.0)
activerecord (>= 5, < 7.1)
active_record-comments (0.8.0)
activerecord (>= 5, < 7.2)

GEM
remote: https://rubygems.org/
Expand Down
4 changes: 2 additions & 2 deletions gemfiles/activerecord_6.0.gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
PATH
remote: ..
specs:
active_record-comments (0.7.0)
activerecord (>= 5, < 7.1)
active_record-comments (0.8.0)
activerecord (>= 5, < 7.2)

GEM
remote: https://rubygems.org/
Expand Down
4 changes: 2 additions & 2 deletions gemfiles/activerecord_6.1.gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
PATH
remote: ..
specs:
active_record-comments (0.7.0)
activerecord (>= 5, < 7.1)
active_record-comments (0.8.0)
activerecord (>= 5, < 7.2)

GEM
remote: https://rubygems.org/
Expand Down
4 changes: 2 additions & 2 deletions gemfiles/activerecord_7.0.gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
PATH
remote: ..
specs:
active_record-comments (0.7.0)
activerecord (>= 5, < 7.1)
active_record-comments (0.8.0)
activerecord (>= 5, < 7.2)

GEM
remote: https://rubygems.org/
Expand Down
6 changes: 6 additions & 0 deletions gemfiles/activerecord_7.1.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
eval_gemfile "common.rb"

gem "activerecord", "~> 7.1.0"
gem "sqlite3", "~> 1.4"

gem 'pry-byebug'
82 changes: 82 additions & 0 deletions gemfiles/activerecord_7.1.gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
PATH
remote: ..
specs:
active_record-comments (0.8.0)
activerecord (>= 5, < 7.2)

GEM
remote: https://rubygems.org/
specs:
activemodel (7.1.2)
activesupport (= 7.1.2)
activerecord (7.1.2)
activemodel (= 7.1.2)
activesupport (= 7.1.2)
timeout (>= 0.4.0)
activesupport (7.1.2)
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)
base64 (0.2.0)
bigdecimal (3.1.5)
bump (0.10.0)
byebug (11.1.3)
coderay (1.1.3)
concurrent-ruby (1.2.2)
connection_pool (2.4.1)
diff-lcs (1.5.0)
drb (2.2.0)
ruby2_keywords
i18n (1.14.1)
concurrent-ruby (~> 1.0)
method_source (1.0.0)
mini_portile2 (2.8.5)
minitest (5.21.1)
mutex_m (0.2.0)
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
pry-byebug (3.10.1)
byebug (~> 11.0)
pry (>= 0.13, < 0.15)
rake (13.1.0)
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)
ruby2_keywords (0.0.5)
sqlite3 (1.7.0)
mini_portile2 (~> 2.8.0)
timeout (0.4.1)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)

PLATFORMS
ruby

DEPENDENCIES
active_record-comments!
activerecord (~> 7.1.0)
bump
pry-byebug
rake
rspec (~> 3.9)
sqlite3 (~> 1.4)

BUNDLED WITH
2.4.21
15 changes: 10 additions & 5 deletions lib/active_record/comments/execute_with_comments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,20 @@ module ExecuteWithComments
class << self
def included(base)
base.class_eval do
# ActiveRecord 7.1
if base.method_defined?(:internal_exec_query)
alias_method :exec_query_without_comment, :internal_exec_query
def internal_exec_query(query, *args, **kwargs, &block)
query = ActiveRecord::Comments.with_comment_sql(query)
exec_query_without_comment(query, *args, **kwargs, &block)
end
# ActiveRecord 3.2 vs sqlite, maybe others ...
if base.method_defined?(:exec_query)
elsif base.method_defined?(:exec_query)
alias_method :exec_query_without_comment, :exec_query
def exec_query(query, *args, prepare: false, &block)
def exec_query(query, *args, **kwargs, &block)
query = ActiveRecord::Comments.with_comment_sql(query)
exec_query_without_comment(query, *args, prepare: prepare, &block)
exec_query_without_comment(query, *args, **kwargs, &block)
end

# 99% case
elsif base.method_defined?(:execute)
alias_method :execute_without_comment, :execute
def execute(query, *args, &block)
Expand Down
2 changes: 1 addition & 1 deletion lib/active_record/comments/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module ActiveRecord
module Comments
VERSION = "0.7.0"
VERSION = "0.8.0"
end
end
13 changes: 11 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,18 @@

ActiveRecord::ConnectionAdapters::SQLite3Adapter.class_eval do
alias_method :exec_query_without_log, :exec_query
def exec_query(query, *args, prepare: false, &block)
def exec_query(query, *args, **kwargs, &block)
LOG << query
exec_query_without_log(query, *args, prepare: prepare, &block)
exec_query_without_log(query, *args, **kwargs, &block)
end

# Rails 7.1.
if ActiveRecord::ConnectionAdapters::SQLite3Adapter.method_defined?(:internal_exec_query)
alias_method :internal_exec_query_without_log, :internal_exec_query
def internal_exec_query(query, *args, **kwargs, &block)
LOG << query
internal_exec_query_without_log(query, *args, **kwargs, &block)
end
end
end

Expand Down

0 comments on commit 70ca910

Please sign in to comment.