diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b49343f..65c528b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,19 +14,13 @@ jobs: matrix: include: # https://github.com/ruby/setup-ruby - - ruby: "head" - activerecord: "7.1" + # - ruby: "head" # cannot test on head as sqlite-ruby requires `ruby < '3.4.dev'` + # activerecord: "8.0" + - ruby: "3.3" + activerecord: "8.0" + - ruby: "3.3" + activerecord: "7.2" - ruby: "3.3" - activerecord: "7.1" - - ruby: "3.2" - activerecord: "7.1" - - ruby: "3.1" - activerecord: "7.1" - - ruby: "3.0" - activerecord: "7.1" - - ruby: "2.7" - activerecord: "7.1" - - ruby: "2.7" activerecord: "6.1" - ruby: "2.7" activerecord: "5.2" @@ -34,13 +28,15 @@ jobs: activerecord: "6.1" - ruby: "2.6" activerecord: "5.2" - - ruby: "jruby-9.4.5" + - ruby: "jruby-9.4.9" activerecord: "6.1" - - ruby: "jruby-9.4.5" - activerecord: "7.0" # latest activerecord-jdbcsqlite3-adapter (70.1) does not support latest rails 7.1 yet - - ruby: "truffleruby-23.1.1" - activerecord: "7.1" - - ruby: "truffleruby-23.1.1" + - ruby: "jruby-9.4.9" + activerecord: "7.2" + - ruby: "truffleruby-24.1.1" + activerecord: "8.0" + - ruby: "truffleruby-24.1.1" + activerecord: "7.2" + - ruby: "truffleruby-24.1.1" activerecord: "6.1" env: @@ -49,7 +45,7 @@ jobs: steps: # https://github.com/actions/checkout - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 # https://github.com/ruby/setup-ruby - name: Set up Ruby ${{ matrix.ruby }} (AR ${{ matrix.activerecord }}) @@ -59,27 +55,27 @@ jobs: bundler-cache: true - name: Install codespell - if: startsWith(matrix.ruby, '3.2') && matrix.activerecord == '7.1' + if: startsWith(matrix.ruby, '3.3') && matrix.activerecord == '8.0' run: | python -m pip install --upgrade pip - pip install codespell==2.2.6 + pip install codespell==2.3.0 - name: Check spelling with codespell - if: startsWith(matrix.ruby, '3.2') && matrix.activerecord == '7.1' + if: startsWith(matrix.ruby, '3.3') && matrix.activerecord == '8.0' run: codespell --skip="./sig,./doc,./coverage,./vendor" || exit 1 # Check code standards only for latest MRI. It takes a lot of time for jruby or truffleruby - name: Check Code Standards - if: startsWith(matrix.ruby, '3.2') && matrix.activerecord == '7.1' + if: startsWith(matrix.ruby, '3.3') && matrix.activerecord == '8.0' run: bundle exec rubocop - name: Run Tests run: bundle exec rspec - name: Markdown linter - if: startsWith(matrix.ruby, '3.2') && matrix.activerecord == '7.1' + if: startsWith(matrix.ruby, '3.3') && matrix.activerecord == '8.0' run: bundle exec mdl README.md CHANGELOG.md RELEASE.md # https://github.com/paambaati/codeclimate-action - name: Publish code coverage to code-climate - uses: paambaati/codeclimate-action@v3.2 - if: (github.event_name == 'push') && startsWith(matrix.ruby, '3.2') + uses: paambaati/codeclimate-action@v9.0.0 + if: (github.event_name == 'push') && startsWith(matrix.ruby, '3.3') diff --git a/.rubocop.yml b/.rubocop.yml index 9927685..d5f9a4d 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -26,9 +26,6 @@ Style/FrozenStringLiteralComment: RSpec/ExampleLength: Enabled: false -RSpec/FilePath: - Enabled: false - RSpec/IndexedLet: Enabled: false diff --git a/CHANGELOG.md b/CHANGELOG.md index 769f305..f0b3328 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,15 +1,17 @@ # CHANGELOG -## [Unreleased] +## [0.21.0] - 2024-11-19 - Allow to provide modifiers and serialization options as strings. Only symbols were allowed previously. +- Test compatibility with ActiveRecord 8.0. + ## [0.20.1] - 2024-02-25 - Fix issue with :if plugin used together with :batch plugin. We kept `key => nil` attribute when key should have been skipped - because of :if_value or :unelss_value option + because of :if_value or :unless_value option ## [0.20.0] - 2023-12-29 diff --git a/Gemfile b/Gemfile index 30c4ee3..cc49cc0 100644 --- a/Gemfile +++ b/Gemfile @@ -7,13 +7,12 @@ gemspec gem "rake", "~> 13.0" gem "rspec", "~> 3.0", require: false -gem "standard", "~> 1.3", require: false +gem "standard", "~> 1.42", require: false gem "simplecov", "~> 0.21", require: false gem "rubocop-rake", "~> 0.6.0", require: false -gem "rubocop-rspec", "~> 2.11", ">= 2.11.1", require: false -gem "rubocop-performance", "~> 1.20", require: false +gem "rubocop-rspec", "~> 3.2.0", require: false +gem "rubocop-performance", "~> 1.22", require: false gem "redcarpet", "~> 3.5", require: false -gem "rspec-sqlimit", "~> 0.0.5", require: false # Can be used in test like: # require 'allocation_stats' # @@ -33,17 +32,6 @@ else gem "pry-byebug", "~> 3.9" end -# ORM plugins -ruby_version = Gem::Version.new(RUBY_VERSION) -ar_version = - if ruby_version >= Gem::Version.new("3.0") - "~> 7.1" - elsif ruby_version >= Gem::Version.new("2.5") - "~> 6.1" - else - "~> 5.2" - end - -gem "activerecord", ar_version +gem "activerecord", "~> 8.0" gem "sqlite3", platforms: [:ruby] gem "activerecord-jdbcsqlite3-adapter", platforms: [:jruby] diff --git a/Gemfile.lock b/Gemfile.lock index 553242b..4600d15 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,160 +1,154 @@ PATH remote: . specs: - serega (0.20.1) + serega (0.21.0) GEM remote: https://rubygems.org/ specs: - activemodel (7.1.3.2) - activesupport (= 7.1.3.2) - activerecord (7.1.3.2) - activemodel (= 7.1.3.2) - activesupport (= 7.1.3.2) + activemodel (8.0.0) + activesupport (= 8.0.0) + activerecord (8.0.0) + activemodel (= 8.0.0) + activesupport (= 8.0.0) timeout (>= 0.4.0) - activesupport (7.1.3.2) + activesupport (8.0.0) base64 + benchmark (>= 0.3) bigdecimal - concurrent-ruby (~> 1.0, >= 1.0.2) + concurrent-ruby (~> 1.0, >= 1.3.1) connection_pool (>= 2.2.5) drb i18n (>= 1.6, < 2) + logger (>= 1.4.2) minitest (>= 5.1) - mutex_m - tzinfo (~> 2.0) + securerandom (>= 0.3) + tzinfo (~> 2.0, >= 2.0.5) + uri (>= 0.13.1) allocation_stats (0.1.5) ast (2.4.2) base64 (0.2.0) - bigdecimal (3.1.6) - chef-utils (18.4.2) + benchmark (0.4.0) + bigdecimal (3.1.8) + chef-utils (18.5.0) concurrent-ruby - concurrent-ruby (1.2.3) + concurrent-ruby (1.3.4) connection_pool (2.4.1) - debug (1.9.1) + debug (1.9.2) irb (~> 1.10) reline (>= 0.3.8) diff-lcs (1.5.1) - docile (1.4.0) - drb (2.2.0) - ruby2_keywords - i18n (1.14.1) + docile (1.4.1) + drb (2.2.1) + i18n (1.14.6) concurrent-ruby (~> 1.0) io-console (0.7.2) - irb (1.11.2) - rdoc + irb (1.14.1) + rdoc (>= 4.0.0) reline (>= 0.4.2) - json (2.7.1) - kramdown (2.4.0) - rexml + json (2.8.2) + kramdown (2.5.1) + rexml (>= 3.3.9) kramdown-parser-gfm (1.1.0) kramdown (~> 2.0) language_server-protocol (3.17.0.3) lint_roller (1.1.0) + logger (1.6.1) mdl (0.13.0) kramdown (~> 2.3) kramdown-parser-gfm (~> 1.1) mixlib-cli (~> 2.1, >= 2.1.1) mixlib-config (>= 2.2.1, < 4) mixlib-shellout - minitest (5.22.2) + minitest (5.25.1) mixlib-cli (2.1.8) mixlib-config (3.0.27) tomlrb - mixlib-shellout (3.2.7) + mixlib-shellout (3.3.4) chef-utils - mutex_m (0.2.0) - parallel (1.24.0) - parser (3.3.0.5) + parallel (1.26.3) + parser (3.3.6.0) ast (~> 2.4.1) racc - psych (5.1.2) + psych (5.2.0) stringio - racc (1.7.3) + racc (1.8.1) rainbow (3.1.1) - rake (13.1.0) - rdoc (6.6.2) + rake (13.2.1) + rdoc (6.7.0) psych (>= 4.0.0) redcarpet (3.6.0) - regexp_parser (2.9.0) - reline (0.4.3) + regexp_parser (2.9.2) + reline (0.5.11) io-console (~> 0.5) - rexml (3.2.6) + rexml (3.3.9) rspec (3.13.0) rspec-core (~> 3.13.0) rspec-expectations (~> 3.13.0) rspec-mocks (~> 3.13.0) - rspec-core (3.13.0) + rspec-core (3.13.2) rspec-support (~> 3.13.0) - rspec-expectations (3.13.0) + rspec-expectations (3.13.3) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) - rspec-mocks (3.13.0) + rspec-mocks (3.13.2) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) - rspec-sqlimit (0.0.6) - activerecord (>= 4.2.0, < 8) - rspec (~> 3.0) rspec-support (3.13.1) - rubocop (1.60.2) + rubocop (1.68.0) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.8, < 3.0) - rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.30.0, < 2.0) + regexp_parser (>= 2.4, < 3.0) + rubocop-ast (>= 1.32.2, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.30.0) - parser (>= 3.2.1.0) - rubocop-capybara (2.20.0) - rubocop (~> 1.41) - rubocop-factory_bot (2.25.1) - rubocop (~> 1.41) - rubocop-performance (1.20.2) + rubocop-ast (1.36.1) + parser (>= 3.3.1.0) + rubocop-performance (1.22.1) rubocop (>= 1.48.1, < 2.0) - rubocop-ast (>= 1.30.0, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) rubocop-rake (0.6.0) rubocop (~> 1.0) - rubocop-rspec (2.26.1) - rubocop (~> 1.40) - rubocop-capybara (~> 2.17) - rubocop-factory_bot (~> 2.22) + rubocop-rspec (3.2.0) + rubocop (~> 1.61) ruby-progressbar (1.13.0) - ruby2_keywords (0.0.5) + securerandom (0.3.2) simplecov (0.22.0) docile (~> 1.1) simplecov-html (~> 0.11) simplecov_json_formatter (~> 0.1) - simplecov-html (0.12.3) + simplecov-html (0.13.1) simplecov_json_formatter (0.1.4) - sqlite3 (1.7.2-x86_64-linux) - standard (1.34.0) + sqlite3 (2.2.0-x86_64-linux-gnu) + standard (1.42.0) language_server-protocol (~> 3.17.0.2) lint_roller (~> 1.0) - rubocop (~> 1.60) + rubocop (~> 1.68.0) standard-custom (~> 1.0.0) - standard-performance (~> 1.3) + standard-performance (~> 1.5) standard-custom (1.0.2) lint_roller (~> 1.0) rubocop (~> 1.50) - standard-performance (1.3.1) + standard-performance (1.5.0) lint_roller (~> 1.1) - rubocop-performance (~> 1.20.2) - stringio (3.1.0) - timeout (0.4.1) + rubocop-performance (~> 1.22.0) + stringio (3.1.2) + timeout (0.4.2) tomlrb (2.0.3) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - unicode-display_width (2.5.0) - yard (0.9.34) + unicode-display_width (2.6.0) + uri (1.0.2) + yard (0.9.37) PLATFORMS x86_64-linux DEPENDENCIES - activerecord (~> 7.1) + activerecord (~> 8.0) activerecord-jdbcsqlite3-adapter allocation_stats debug (>= 1.0.0) @@ -162,15 +156,14 @@ DEPENDENCIES rake (~> 13.0) redcarpet (~> 3.5) rspec (~> 3.0) - rspec-sqlimit (~> 0.0.5) - rubocop-performance (~> 1.20) + rubocop-performance (~> 1.22) rubocop-rake (~> 0.6.0) - rubocop-rspec (~> 2.11, >= 2.11.1) + rubocop-rspec (~> 3.2.0) serega! simplecov (~> 0.21) sqlite3 - standard (~> 1.3) + standard (~> 1.42) yard BUNDLED WITH - 2.5.6 + 2.5.23 diff --git a/RELEASE.md b/RELEASE.md index c088901..223d82d 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -14,8 +14,8 @@ && bundle update && bundle update --bundler \ && BUNDLE_GEMFILE=gemfiles/5.2.gemfile bundle update \ && BUNDLE_GEMFILE=gemfiles/6.1.gemfile bundle update \ - && BUNDLE_GEMFILE=gemfiles/7.0.gemfile bundle update \ - && BUNDLE_GEMFILE=gemfiles/7.1.gemfile bundle update \ + && BUNDLE_GEMFILE=gemfiles/7.2.gemfile bundle update \ + && BUNDLE_GEMFILE=gemfiles/8.0.gemfile bundle update \ && bundle exec rspec \ && bundle exec rubocop -A \ && bundle exec rake examples \ @@ -44,6 +44,7 @@ && BUNDLE_GEMFILE=gemfiles/6.1.gemfile bundle update \ && BUNDLE_GEMFILE=gemfiles/7.0.gemfile bundle update \ && BUNDLE_GEMFILE=gemfiles/7.1.gemfile bundle update \ + && BUNDLE_GEMFILE=gemfiles/8.0.gemfile bundle update \ && bundle exec rspec \ && bundle exec rubocop -A \ && bundle exec rake examples \ diff --git a/VERSION b/VERSION index 847e9ae..8854156 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.20.1 +0.21.0 diff --git a/gemfiles/5.2.gemfile b/gemfiles/5.2.gemfile index 30b6c8f..d16f671 100644 --- a/gemfiles/5.2.gemfile +++ b/gemfiles/5.2.gemfile @@ -8,6 +8,5 @@ gem "activerecord", "~> 5.2.3" gem "rake", "~> 13.0" gem "rspec", "~> 3.11", require: false -gem "rspec-sqlimit", "~> 0.0.5", require: false gemspec name: "serega", path: "../" diff --git a/gemfiles/5.2.gemfile.lock b/gemfiles/5.2.gemfile.lock index bcd8e3b..2179a2f 100644 --- a/gemfiles/5.2.gemfile.lock +++ b/gemfiles/5.2.gemfile.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - serega (0.20.1) + serega (0.21.0) GEM remote: https://rubygems.org/ @@ -23,29 +23,26 @@ GEM minitest (~> 5.1) tzinfo (~> 1.1) arel (9.0.0) - concurrent-ruby (1.2.3) + concurrent-ruby (1.3.4) diff-lcs (1.5.1) - i18n (1.14.1) + i18n (1.14.6) concurrent-ruby (~> 1.0) jdbc-sqlite3 (3.28.0) - mini_portile2 (2.8.5) - minitest (5.22.2) - rake (13.1.0) + mini_portile2 (2.8.8) + minitest (5.25.1) + rake (13.2.1) rspec (3.13.0) rspec-core (~> 3.13.0) rspec-expectations (~> 3.13.0) rspec-mocks (~> 3.13.0) - rspec-core (3.13.0) + rspec-core (3.13.2) rspec-support (~> 3.13.0) - rspec-expectations (3.13.0) + rspec-expectations (3.13.3) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) - rspec-mocks (3.13.0) + rspec-mocks (3.13.2) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) - rspec-sqlimit (0.0.6) - activerecord (>= 4.2.0, < 8) - rspec (~> 3.0) rspec-support (3.13.1) sqlite3 (1.5.4) mini_portile2 (~> 2.8.0) @@ -63,9 +60,8 @@ DEPENDENCIES activerecord-jdbcsqlite3-adapter rake (~> 13.0) rspec (~> 3.11) - rspec-sqlimit (~> 0.0.5) serega! sqlite3 (~> 1.5.4) BUNDLED WITH - 2.4.22 + 2.5.23 diff --git a/gemfiles/6.1.gemfile b/gemfiles/6.1.gemfile index ad9b8b4..ec9a257 100644 --- a/gemfiles/6.1.gemfile +++ b/gemfiles/6.1.gemfile @@ -8,6 +8,5 @@ gem "activerecord-jdbcsqlite3-adapter", "61.0", platforms: [:jruby] gem "rake", "~> 13.0" gem "rspec", "~> 3.11", require: false -gem "rspec-sqlimit", "~> 0.0.5", require: false gemspec name: "serega", path: "../" diff --git a/gemfiles/6.1.gemfile.lock b/gemfiles/6.1.gemfile.lock index 7b5e4fc..d2ceaff 100644 --- a/gemfiles/6.1.gemfile.lock +++ b/gemfiles/6.1.gemfile.lock @@ -1,54 +1,51 @@ PATH remote: .. specs: - serega (0.20.1) + serega (0.21.0) GEM remote: https://rubygems.org/ specs: - activemodel (6.1.7.7) - activesupport (= 6.1.7.7) - activerecord (6.1.7.7) - activemodel (= 6.1.7.7) - activesupport (= 6.1.7.7) + activemodel (6.1.7.10) + activesupport (= 6.1.7.10) + activerecord (6.1.7.10) + activemodel (= 6.1.7.10) + activesupport (= 6.1.7.10) activerecord-jdbc-adapter (61.0-java) activerecord (~> 6.1.0) activerecord-jdbcsqlite3-adapter (61.0-java) activerecord-jdbc-adapter (= 61.0) jdbc-sqlite3 (~> 3.8, < 3.30) - activesupport (6.1.7.7) + activesupport (6.1.7.10) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) zeitwerk (~> 2.3) - concurrent-ruby (1.2.3) + concurrent-ruby (1.3.4) diff-lcs (1.5.1) - i18n (1.14.1) + i18n (1.14.6) concurrent-ruby (~> 1.0) jdbc-sqlite3 (3.28.0) - minitest (5.22.2) - rake (13.1.0) + minitest (5.25.1) + rake (13.2.1) rspec (3.13.0) rspec-core (~> 3.13.0) rspec-expectations (~> 3.13.0) rspec-mocks (~> 3.13.0) - rspec-core (3.13.0) + rspec-core (3.13.2) rspec-support (~> 3.13.0) - rspec-expectations (3.13.0) + rspec-expectations (3.13.3) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) - rspec-mocks (3.13.0) + rspec-mocks (3.13.2) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) - rspec-sqlimit (0.0.6) - activerecord (>= 4.2.0, < 8) - rspec (~> 3.0) rspec-support (3.13.1) sqlite3 (1.4.4) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - zeitwerk (2.6.13) + zeitwerk (2.7.1) PLATFORMS universal-java-11 @@ -59,9 +56,8 @@ DEPENDENCIES activerecord-jdbcsqlite3-adapter (= 61.0) rake (~> 13.0) rspec (~> 3.11) - rspec-sqlimit (~> 0.0.5) serega! sqlite3 (~> 1.4.4) BUNDLED WITH - 2.4.22 + 2.5.23 diff --git a/gemfiles/7.0.gemfile b/gemfiles/7.0.gemfile deleted file mode 100644 index 71ad4bb..0000000 --- a/gemfiles/7.0.gemfile +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -source "https://rubygems.org" - -gem "sqlite3", "~> 1.4.4", platforms: [:ruby] -gem "activerecord", "7.0.8" -gem "activerecord-jdbcsqlite3-adapter", "~> 70.1", platforms: [:jruby] - -gem "rake", "~> 13.0" -gem "standard", "~> 1.12", ">= 1.12.1", require: false -gem "rspec", "~> 3.11", require: false -gem "simplecov", "~> 0.21.2", require: false -gem "rubocop-rake", "~> 0.6.0", require: false -gem "rubocop-rspec", "~> 2.11", ">= 2.11.1", require: false -gem "rspec-sqlimit", "~> 0.0.5", require: false -gem "mdl", "~> 0.12.0", require: false - -gemspec name: "serega", path: "../" diff --git a/gemfiles/7.0.gemfile.lock b/gemfiles/7.0.gemfile.lock deleted file mode 100644 index db18ab8..0000000 --- a/gemfiles/7.0.gemfile.lock +++ /dev/null @@ -1,149 +0,0 @@ -PATH - remote: .. - specs: - serega (0.20.1) - -GEM - remote: https://rubygems.org/ - specs: - activemodel (7.0.8) - activesupport (= 7.0.8) - activerecord (7.0.8) - activemodel (= 7.0.8) - activesupport (= 7.0.8) - activerecord-jdbc-adapter (70.1-java) - activerecord (~> 7.0) - activerecord-jdbcsqlite3-adapter (70.1-java) - activerecord-jdbc-adapter (= 70.1) - jdbc-sqlite3 (~> 3.8, < 3.34) - activesupport (7.0.8) - concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 1.6, < 2) - minitest (>= 5.1) - tzinfo (~> 2.0) - ast (2.4.2) - chef-utils (18.4.2) - concurrent-ruby - concurrent-ruby (1.2.3) - diff-lcs (1.5.1) - docile (1.4.0) - i18n (1.14.1) - concurrent-ruby (~> 1.0) - jdbc-sqlite3 (3.32.3.3) - json (2.7.1) - json (2.7.1-java) - kramdown (2.4.0) - rexml - kramdown-parser-gfm (1.1.0) - kramdown (~> 2.0) - language_server-protocol (3.17.0.3) - lint_roller (1.1.0) - mdl (0.12.0) - kramdown (~> 2.3) - kramdown-parser-gfm (~> 1.1) - mixlib-cli (~> 2.1, >= 2.1.1) - mixlib-config (>= 2.2.1, < 4) - mixlib-shellout - minitest (5.22.2) - mixlib-cli (2.1.8) - mixlib-config (3.0.27) - tomlrb - mixlib-shellout (3.2.7) - chef-utils - parallel (1.24.0) - parser (3.3.0.5) - ast (~> 2.4.1) - racc - racc (1.7.3) - racc (1.7.3-java) - rainbow (3.1.1) - rake (13.1.0) - regexp_parser (2.9.0) - rexml (3.2.6) - rspec (3.13.0) - rspec-core (~> 3.13.0) - rspec-expectations (~> 3.13.0) - rspec-mocks (~> 3.13.0) - rspec-core (3.13.0) - rspec-support (~> 3.13.0) - rspec-expectations (3.13.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.13.0) - rspec-mocks (3.13.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.13.0) - rspec-sqlimit (0.0.6) - activerecord (>= 4.2.0, < 8) - rspec (~> 3.0) - rspec-support (3.13.1) - rubocop (1.60.2) - json (~> 2.3) - language_server-protocol (>= 3.17.0) - parallel (~> 1.10) - parser (>= 3.3.0.2) - rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.8, < 3.0) - rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.30.0, < 2.0) - ruby-progressbar (~> 1.7) - unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.30.0) - parser (>= 3.2.1.0) - rubocop-capybara (2.20.0) - rubocop (~> 1.41) - rubocop-factory_bot (2.25.1) - rubocop (~> 1.41) - rubocop-performance (1.20.2) - rubocop (>= 1.48.1, < 2.0) - rubocop-ast (>= 1.30.0, < 2.0) - rubocop-rake (0.6.0) - rubocop (~> 1.0) - rubocop-rspec (2.26.1) - rubocop (~> 1.40) - rubocop-capybara (~> 2.17) - rubocop-factory_bot (~> 2.22) - ruby-progressbar (1.13.0) - simplecov (0.21.2) - docile (~> 1.1) - simplecov-html (~> 0.11) - simplecov_json_formatter (~> 0.1) - simplecov-html (0.12.3) - simplecov_json_formatter (0.1.4) - sqlite3 (1.4.4) - standard (1.34.0) - language_server-protocol (~> 3.17.0.2) - lint_roller (~> 1.0) - rubocop (~> 1.60) - standard-custom (~> 1.0.0) - standard-performance (~> 1.3) - standard-custom (1.0.2) - lint_roller (~> 1.0) - rubocop (~> 1.50) - standard-performance (1.3.1) - lint_roller (~> 1.1) - rubocop-performance (~> 1.20.2) - tomlrb (2.0.3) - tzinfo (2.0.6) - concurrent-ruby (~> 1.0) - unicode-display_width (2.5.0) - -PLATFORMS - universal-java-11 - x86_64-linux - -DEPENDENCIES - activerecord (= 7.0.8) - activerecord-jdbcsqlite3-adapter (~> 70.1) - mdl (~> 0.12.0) - rake (~> 13.0) - rspec (~> 3.11) - rspec-sqlimit (~> 0.0.5) - rubocop-rake (~> 0.6.0) - rubocop-rspec (~> 2.11, >= 2.11.1) - serega! - simplecov (~> 0.21.2) - sqlite3 (~> 1.4.4) - standard (~> 1.12, >= 1.12.1) - -BUNDLED WITH - 2.4.22 diff --git a/gemfiles/7.1.gemfile.lock b/gemfiles/7.1.gemfile.lock deleted file mode 100644 index bdea62f..0000000 --- a/gemfiles/7.1.gemfile.lock +++ /dev/null @@ -1,164 +0,0 @@ -PATH - remote: .. - specs: - serega (0.20.1) - -GEM - remote: https://rubygems.org/ - specs: - activemodel (7.1.3.2) - activesupport (= 7.1.3.2) - activerecord (7.1.3.2) - activemodel (= 7.1.3.2) - activesupport (= 7.1.3.2) - timeout (>= 0.4.0) - activerecord-jdbc-adapter (70.1-java) - activerecord (~> 7.0) - activerecord-jdbcsqlite3-adapter (70.1-java) - activerecord-jdbc-adapter (= 70.1) - jdbc-sqlite3 (~> 3.8, < 3.34) - activesupport (7.1.3.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) - ast (2.4.2) - base64 (0.2.0) - bigdecimal (3.1.6) - bigdecimal (3.1.6-java) - chef-utils (18.4.2) - concurrent-ruby - concurrent-ruby (1.2.3) - connection_pool (2.4.1) - diff-lcs (1.5.1) - docile (1.4.0) - drb (2.2.0) - ruby2_keywords - i18n (1.14.1) - concurrent-ruby (~> 1.0) - jdbc-sqlite3 (3.32.3.3) - json (2.7.1) - json (2.7.1-java) - kramdown (2.4.0) - rexml - kramdown-parser-gfm (1.1.0) - kramdown (~> 2.0) - language_server-protocol (3.17.0.3) - lint_roller (1.1.0) - mdl (0.12.0) - kramdown (~> 2.3) - kramdown-parser-gfm (~> 1.1) - mixlib-cli (~> 2.1, >= 2.1.1) - mixlib-config (>= 2.2.1, < 4) - mixlib-shellout - minitest (5.22.2) - mixlib-cli (2.1.8) - mixlib-config (3.0.27) - tomlrb - mixlib-shellout (3.2.7) - chef-utils - mutex_m (0.2.0) - parallel (1.24.0) - parser (3.3.0.5) - ast (~> 2.4.1) - racc - racc (1.7.3) - racc (1.7.3-java) - rainbow (3.1.1) - rake (13.1.0) - regexp_parser (2.9.0) - rexml (3.2.6) - rspec (3.13.0) - rspec-core (~> 3.13.0) - rspec-expectations (~> 3.13.0) - rspec-mocks (~> 3.13.0) - rspec-core (3.13.0) - rspec-support (~> 3.13.0) - rspec-expectations (3.13.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.13.0) - rspec-mocks (3.13.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.13.0) - rspec-sqlimit (0.0.6) - activerecord (>= 4.2.0, < 8) - rspec (~> 3.0) - rspec-support (3.13.1) - rubocop (1.60.2) - json (~> 2.3) - language_server-protocol (>= 3.17.0) - parallel (~> 1.10) - parser (>= 3.3.0.2) - rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.8, < 3.0) - rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.30.0, < 2.0) - ruby-progressbar (~> 1.7) - unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.30.0) - parser (>= 3.2.1.0) - rubocop-capybara (2.20.0) - rubocop (~> 1.41) - rubocop-factory_bot (2.25.1) - rubocop (~> 1.41) - rubocop-performance (1.20.2) - rubocop (>= 1.48.1, < 2.0) - rubocop-ast (>= 1.30.0, < 2.0) - rubocop-rake (0.6.0) - rubocop (~> 1.0) - rubocop-rspec (2.26.1) - rubocop (~> 1.40) - rubocop-capybara (~> 2.17) - rubocop-factory_bot (~> 2.22) - ruby-progressbar (1.13.0) - ruby2_keywords (0.0.5) - simplecov (0.21.2) - docile (~> 1.1) - simplecov-html (~> 0.11) - simplecov_json_formatter (~> 0.1) - simplecov-html (0.12.3) - simplecov_json_formatter (0.1.4) - sqlite3 (1.4.4) - standard (1.34.0) - language_server-protocol (~> 3.17.0.2) - lint_roller (~> 1.0) - rubocop (~> 1.60) - standard-custom (~> 1.0.0) - standard-performance (~> 1.3) - standard-custom (1.0.2) - lint_roller (~> 1.0) - rubocop (~> 1.50) - standard-performance (1.3.1) - lint_roller (~> 1.1) - rubocop-performance (~> 1.20.2) - timeout (0.4.1) - tomlrb (2.0.3) - tzinfo (2.0.6) - concurrent-ruby (~> 1.0) - unicode-display_width (2.5.0) - -PLATFORMS - universal-java-11 - x86_64-linux - -DEPENDENCIES - activerecord (~> 7.1, >= 7.1.1) - activerecord-jdbcsqlite3-adapter - mdl (~> 0.12.0) - rake (~> 13.0) - rspec (~> 3.11) - rspec-sqlimit (~> 0.0.5) - rubocop-rake (~> 0.6.0) - rubocop-rspec (~> 2.11, >= 2.11.1) - serega! - simplecov (~> 0.21.2) - sqlite3 (~> 1.4.4) - standard (~> 1.12, >= 1.12.1) - -BUNDLED WITH - 2.4.22 diff --git a/gemfiles/7.2.gemfile b/gemfiles/7.2.gemfile new file mode 100644 index 0000000..a0fbc50 --- /dev/null +++ b/gemfiles/7.2.gemfile @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +source "https://rubygems.org" + +gem "activerecord-jdbcsqlite3-adapter", platforms: [:jruby] +gem "sqlite3", "~> 1.4.4", platforms: [:ruby] +gem "activerecord", "~> 7.2" + +gem "rake", "~> 13.0" +gem "rspec", "~> 3.11", require: false + +gemspec name: "serega", path: "../" diff --git a/gemfiles/7.2.gemfile.lock b/gemfiles/7.2.gemfile.lock new file mode 100644 index 0000000..01bba65 --- /dev/null +++ b/gemfiles/7.2.gemfile.lock @@ -0,0 +1,78 @@ +PATH + remote: .. + specs: + serega (0.21.0) + +GEM + remote: https://rubygems.org/ + specs: + activemodel (7.2.2) + activesupport (= 7.2.2) + activerecord (7.2.2) + activemodel (= 7.2.2) + activesupport (= 7.2.2) + timeout (>= 0.4.0) + activerecord-jdbc-adapter (70.2-java) + activerecord (~> 7.0) + activerecord-jdbcsqlite3-adapter (70.2-java) + activerecord-jdbc-adapter (= 70.2) + jdbc-sqlite3 (~> 3.8) + activesupport (7.2.2) + base64 + benchmark (>= 0.3) + bigdecimal + concurrent-ruby (~> 1.0, >= 1.3.1) + connection_pool (>= 2.2.5) + drb + i18n (>= 1.6, < 2) + logger (>= 1.4.2) + minitest (>= 5.1) + securerandom (>= 0.3) + tzinfo (~> 2.0, >= 2.0.5) + base64 (0.2.0) + benchmark (0.4.0) + bigdecimal (3.1.8) + bigdecimal (3.1.8-java) + concurrent-ruby (1.3.4) + connection_pool (2.4.1) + diff-lcs (1.5.1) + drb (2.2.1) + i18n (1.14.6) + concurrent-ruby (~> 1.0) + jdbc-sqlite3 (3.46.1.1) + logger (1.6.1) + minitest (5.25.1) + rake (13.2.1) + rspec (3.13.0) + rspec-core (~> 3.13.0) + rspec-expectations (~> 3.13.0) + rspec-mocks (~> 3.13.0) + rspec-core (3.13.2) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.3) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.2) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-support (3.13.1) + securerandom (0.3.2) + sqlite3 (1.4.4) + timeout (0.4.2) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) + +PLATFORMS + universal-java-11 + x86_64-linux + +DEPENDENCIES + activerecord (~> 7.2) + activerecord-jdbcsqlite3-adapter + rake (~> 13.0) + rspec (~> 3.11) + serega! + sqlite3 (~> 1.4.4) + +BUNDLED WITH + 2.5.23 diff --git a/gemfiles/7.1.gemfile b/gemfiles/8.0.gemfile similarity index 53% rename from gemfiles/7.1.gemfile rename to gemfiles/8.0.gemfile index 1e85a61..3f62343 100644 --- a/gemfiles/7.1.gemfile +++ b/gemfiles/8.0.gemfile @@ -3,16 +3,15 @@ source "https://rubygems.org" gem "activerecord-jdbcsqlite3-adapter", platforms: [:jruby] -gem "sqlite3", "~> 1.4.4", platforms: [:ruby] -gem "activerecord", "~> 7.1", ">= 7.1.1" +gem "sqlite3", "~> 2.2.0", platforms: [:ruby] +gem "activerecord", "~> 8.0" gem "rake", "~> 13.0" gem "standard", "~> 1.12", ">= 1.12.1", require: false gem "rspec", "~> 3.11", require: false -gem "simplecov", "~> 0.21.2", require: false +gem "simplecov", "~> 0.22", require: false gem "rubocop-rake", "~> 0.6.0", require: false -gem "rubocop-rspec", "~> 2.11", ">= 2.11.1", require: false -gem "rspec-sqlimit", "~> 0.0.5", require: false -gem "mdl", "~> 0.12.0", require: false +gem "rubocop-rspec", "~> 3.2.0", require: false +gem "mdl", "~> 0.13.0", require: false gemspec name: "serega", path: "../" diff --git a/gemfiles/8.0.gemfile.lock b/gemfiles/8.0.gemfile.lock new file mode 100644 index 0000000..a03f674 --- /dev/null +++ b/gemfiles/8.0.gemfile.lock @@ -0,0 +1,151 @@ +PATH + remote: .. + specs: + serega (0.21.0) + +GEM + remote: https://rubygems.org/ + specs: + activemodel (8.0.0) + activesupport (= 8.0.0) + activerecord (8.0.0) + activemodel (= 8.0.0) + activesupport (= 8.0.0) + timeout (>= 0.4.0) + activesupport (8.0.0) + base64 + benchmark (>= 0.3) + bigdecimal + concurrent-ruby (~> 1.0, >= 1.3.1) + connection_pool (>= 2.2.5) + drb + i18n (>= 1.6, < 2) + logger (>= 1.4.2) + minitest (>= 5.1) + securerandom (>= 0.3) + tzinfo (~> 2.0, >= 2.0.5) + uri (>= 0.13.1) + ast (2.4.2) + base64 (0.2.0) + benchmark (0.4.0) + bigdecimal (3.1.8) + chef-utils (18.5.0) + concurrent-ruby + concurrent-ruby (1.3.4) + connection_pool (2.4.1) + diff-lcs (1.5.1) + docile (1.4.1) + drb (2.2.1) + i18n (1.14.6) + concurrent-ruby (~> 1.0) + json (2.8.2) + kramdown (2.5.1) + rexml (>= 3.3.9) + kramdown-parser-gfm (1.1.0) + kramdown (~> 2.0) + language_server-protocol (3.17.0.3) + lint_roller (1.1.0) + logger (1.6.1) + mdl (0.13.0) + kramdown (~> 2.3) + kramdown-parser-gfm (~> 1.1) + mixlib-cli (~> 2.1, >= 2.1.1) + mixlib-config (>= 2.2.1, < 4) + mixlib-shellout + mini_portile2 (2.8.8) + minitest (5.25.1) + mixlib-cli (2.1.8) + mixlib-config (3.0.27) + tomlrb + mixlib-shellout (3.3.4) + chef-utils + parallel (1.26.3) + parser (3.3.6.0) + ast (~> 2.4.1) + racc + racc (1.8.1) + rainbow (3.1.1) + rake (13.2.1) + regexp_parser (2.9.2) + rexml (3.3.9) + rspec (3.13.0) + rspec-core (~> 3.13.0) + rspec-expectations (~> 3.13.0) + rspec-mocks (~> 3.13.0) + rspec-core (3.13.2) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.3) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.2) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-support (3.13.1) + rubocop (1.68.0) + json (~> 2.3) + language_server-protocol (>= 3.17.0) + parallel (~> 1.10) + parser (>= 3.3.0.2) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 2.4, < 3.0) + rubocop-ast (>= 1.32.2, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.36.1) + parser (>= 3.3.1.0) + rubocop-performance (1.22.1) + rubocop (>= 1.48.1, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) + rubocop-rake (0.6.0) + rubocop (~> 1.0) + rubocop-rspec (3.2.0) + rubocop (~> 1.61) + ruby-progressbar (1.13.0) + securerandom (0.3.2) + simplecov (0.22.0) + docile (~> 1.1) + simplecov-html (~> 0.11) + simplecov_json_formatter (~> 0.1) + simplecov-html (0.13.1) + simplecov_json_formatter (0.1.4) + sqlite3 (2.2.0) + mini_portile2 (~> 2.8.0) + sqlite3 (2.2.0-x86_64-linux-gnu) + standard (1.42.0) + language_server-protocol (~> 3.17.0.2) + lint_roller (~> 1.0) + rubocop (~> 1.68.0) + standard-custom (~> 1.0.0) + standard-performance (~> 1.5) + standard-custom (1.0.2) + lint_roller (~> 1.0) + rubocop (~> 1.50) + standard-performance (1.5.0) + lint_roller (~> 1.1) + rubocop-performance (~> 1.22.0) + timeout (0.4.2) + tomlrb (2.0.3) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) + unicode-display_width (2.6.0) + uri (1.0.2) + +PLATFORMS + ruby + x86_64-linux + +DEPENDENCIES + activerecord (~> 8.0) + activerecord-jdbcsqlite3-adapter + mdl (~> 0.13.0) + rake (~> 13.0) + rspec (~> 3.11) + rubocop-rake (~> 0.6.0) + rubocop-rspec (~> 3.2.0) + serega! + simplecov (~> 0.22) + sqlite3 (~> 2.2.0) + standard (~> 1.12, >= 1.12.1) + +BUNDLED WITH + 2.5.23 diff --git a/spec/serega/plugins/batch/lib/plugin_extensions/activerecord_preloads_spec.rb b/spec/serega/plugins/batch/lib/plugin_extensions/activerecord_preloads_spec.rb index b623165..3cae583 100644 --- a/spec/serega/plugins/batch/lib/plugin_extensions/activerecord_preloads_spec.rb +++ b/spec/serega/plugins/batch/lib/plugin_extensions/activerecord_preloads_spec.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true require "support/activerecord" -require "rspec-sqlimit" load_plugin_code :batch @@ -71,13 +70,17 @@ def groups(values, by:) it "preloads data to batch loaded records", :with_rollback do users = AR::User.all - result = nil - expect { result = user_serializer.to_h(users) }.not_to exceed_query_limit(3) + queries_count = 0 + ActiveSupport::Notifications.subscribe("sql.active_record") { queries_count += 1 } + + result = user_serializer.to_h(users) expect(result.count).to eq 1 # 1 user expect(result[0][:posts].count).to eq 2 # 2 posts expect(result[0][:posts][0][:comments].count).to eq 2 # 2 comments of post1 expect(result[0][:posts][1][:comments].count).to eq 1 # 1 comment of post2 + + expect(queries_count).to eq 3 end end @@ -102,11 +105,15 @@ def groups(values, by:) it "preloads data correctly", :with_rollback do users = AR::User.all - result = nil - expect { result = user_serializer.to_h(users) }.not_to exceed_query_limit(3) + queries_count = 0 + ActiveSupport::Notifications.subscribe("sql.active_record") { queries_count += 1 } + + result = user_serializer.to_h(users) expect(result[0][:posts_count]).to eq 2 expect(result[0][:comments_count]).to eq 3 + + expect(queries_count).to eq 3 end end @@ -146,14 +153,17 @@ def groups(values, by:) it "preloads data to batch loaded records", :with_rollback do users = AR::User.all + queries_count = 0 + ActiveSupport::Notifications.subscribe("sql.active_record") { queries_count += 1 } - result = nil - expect { result = user_serializer.to_h(users) }.not_to exceed_query_limit(3) + result = user_serializer.to_h(users) expect(result.count).to eq 1 # 1 user expect(result[0][:posts].count).to eq 2 # 2 posts expect(result[0][:posts][0][:comments].count).to eq 2 # 2 comments of post1 expect(result[0][:posts][1][:comments].count).to eq 1 # 1 comment of post2 + + expect(queries_count).to eq 3 end end end diff --git a/spec/serega/plugins/presenter/presenter_spec.rb b/spec/serega/plugins/presenter/presenter_spec.rb index 95933ca..ce6d97f 100644 --- a/spec/serega/plugins/presenter/presenter_spec.rb +++ b/spec/serega/plugins/presenter/presenter_spec.rb @@ -53,8 +53,10 @@ def value end it "works in nested relation" do + struct = Struct.new(:nested).new("123") + current_serializer = serializer - serializer.attribute(:rev) { |obj| obj.rev } + current_serializer.attribute(:rev) current_serializer::Presenter.class_exec do def rev reverse @@ -65,9 +67,7 @@ def rev attribute :nested, serializer: current_serializer end - base = OpenStruct.new(nested: "123") - - result = base_serializer.new.to_h(base) + result = base_serializer.new.to_h(struct, many: false) expect(result).to eq({nested: {rev: "321"}}) end end diff --git a/spec/support/activerecord.rb b/spec/support/activerecord.rb index c6b30c8..e4107d3 100644 --- a/spec/support/activerecord.rb +++ b/spec/support/activerecord.rb @@ -2,7 +2,7 @@ require "active_record" -conn = ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:").connection +conn = ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:").lease_connection conn.create_table(:users) do |t| t.string :first_name