Commit Graph

91611 Commits

Author SHA1 Message Date
Andrew Novoselac 4c243279ac Fix outdated Gemfile.lock
rails/rails@8eae753 removed jruby and oracle gems from the Gemfile but did not update Gemfile.lock
2024-05-14 12:36:55 -04:00
Carlos Antonio da Silva 0be846c893
Merge pull request #51758 from taketo1113/fix-changed-cidr2
PostgreSQL Cidr#change? raise an error of NoMethodError: undefined method `prefix' for nil, when creating a record with an empty value of inet/cidr column.
2024-05-14 09:59:51 -03:00
Ryuta Kamizono 1b6b1a9cb9
Merge pull request #51788 from fatkodima/batch_enumerator-destroy_all-returns-rows-number
Change `BatchEnumerator#destroy_all` to return the total number of affected rows
2024-05-14 21:13:55 +09:00
Jean Boussier a8d26789a4
Merge pull request #51815 from byroot/cached-find-by-connection-lease
Eliminate `lease_connection` call in `cached_find_by`
2024-05-14 15:20:07 +09:00
Jean Boussier 33f6c49118 Appease the linter 2024-05-14 15:19:03 +09:00
Jean Boussier 4ca838b899 Eliminate `lease_connection` call in `cached_find_by`
Fix: https://github.com/rails/rails/issues/51811
2024-05-14 15:12:12 +09:00
Jean Boussier 2e7dc14943
Merge pull request #51810 from Shopify/cache-association-loaded
Only serialize associations that were loaded
2024-05-14 09:37:39 +09:00
Jean Boussier db4dba78c9 Only serialize associations that were loaded
Fix: https://github.com/rails/rails/issues/51807

`association_cached?` only means the Association object was
created, not that the records were loaded.

Co-Authored-By: benk-gc <bkyriakou@gocardless.com>
2024-05-14 09:37:23 +09:00
David Heinemeier Hansson bee3fa41ca
Add Kamal by default to Rails 8 (#51798)
* Add Kamal by default
2024-05-13 17:32:42 -07:00
Taketo Takashima c395b99f11 Fix PostgreSQL Cidr#change?: NoMethodError: undefined method `prefix` for nil 2024-05-14 08:43:51 +09:00
fatkodima 94af7c181a Change `BatchEnumerator#destroy_all` to return the total number of affected rows 2024-05-13 22:54:25 +03:00
Rafael Mendonça França 8eae75379c
Remove jruby and oracle related gems from Gemfile
We are only know goign to support mysql2, trilogy, postgresql and sqlite3
adapters in Rails.
2024-05-13 19:19:04 +00:00
Ryuta Kamizono 36885949a9
Merge pull request #51787 from fatkodima/fix-touch_all-with-aliased-attribute-for-update
Fix `ActiveRecord::Relation#touch_all` with custom attribute aliased as attribute for update
2024-05-14 03:55:58 +09:00
Rafael Mendonça França a0e8ea1341
Add Highlights section in the Rails 7.1 release notes 2024-05-13 18:41:52 +00:00
Rafael Mendonça França 66eda9c1d9
Merge pull request #51789 from Shopify/reference-devcontainer-guides-in-dockerfile
Reference the dev container guides in a comment in the production doc…
2024-05-13 14:29:20 -04:00
Rafael Mendonça França a70d89c519
Merge pull request #51766 from Shopify/revert-actionable-errors-retry
Revert "Merge pull request #50941 from andrewn617/actionable-cli"
2024-05-13 18:28:42 +00:00
Rafael Mendonça França a4d58ddea7
This will be released in 7.2 2024-05-13 18:20:53 +00:00
Rafael Mendonça França cb1c789ca2
Merge pull request #51765 from Shopify/refactor-devcontainer-implementation
Clean up database generators implementation
2024-05-13 14:19:44 -04:00
Andrew Novoselac eeec15c02c Point user to devcontainer for containerized dev environment 2024-05-13 14:12:14 -04:00
Rafael Mendonça França 5c933a3d82
Merge pull request #51791 from duduribeiro/add-name-to-devcontainer-compose
Add name to DevContainer compose file
2024-05-13 14:10:47 -04:00
Andrew Novoselac c1bc7ee82e Refactoring Database generators
Extract all the DB information (gems, dockerfile packages, devcontainer etc.) into an object. This let's us remove the growing number of case statements in this code.
2024-05-13 14:07:47 -04:00
Andrew Novoselac 5b91084f20 Remove support for oracle, sqlserver and JRuby specific database adapters from the new and db:system:change commands. The supported options are sqlite3, mysql, postgresql and trilogy. 2024-05-13 14:07:47 -04:00
Rafael Mendonça França 3e08223ece
Fix rubocop
See https://github.com/rubocop/rubocop/issues/12898 for the issue.
2024-05-13 18:04:01 +00:00
Cadu Ribeiro f63d344ce9 Add name to DevContainer compose file
Currently when you generate a project the compose.yaml generated
file does not include the top-level name property. Not having this
top-level name property makes all containers / volumes started by
devcontainer to be prepended with the folder name, which is
`devcontainer` in the case of the .devcontainer/compose.yml` file.

This is ok if you run only one project with devcontainer but starts
to get problem if you run multiple projects. If you have one project
that runs on postgresql 15 and a new one that runs on postgresql 16 it
will fail to boot the postgresql container because both devcontainers is
using the same volume: `devcontainer_postgres-data`.

This commit fixes this by setting the top-lavel name property with
the project name, which will make the containers and volumes to be
prepended with the project name and not with `devcontainer`.
2024-05-13 14:26:46 -03:00
Rafael Mendonça França bf59d363fb
Clean CHANGELOG for 8.0 2024-05-13 16:55:52 +00:00
Rafael Mendonça França dc96d29d2b
Reapply "Rails 8 will target Ruby 3.3+ only for new apps"
This reverts commit 64ab211892.
2024-05-13 16:46:39 +00:00
Rafael Mendonça França 37fd0e7fe4
Development of Rails 8.0 starts now
🎉
2024-05-13 16:45:20 +00:00
Carlos Antonio da Silva a6e2bb04dd
Merge pull request #51651 from heka1024/support-duration-in-xml
Support duration in `ActiveSupport::XmlMini`
2024-05-13 13:34:50 -03:00
Rafael Mendonça França 749d337809
Merge pull request #51804 from zzak/lint-debugger
Enable Lint/Debugger
2024-05-13 12:27:50 -04:00
Rafael Mendonça França 48d628501f
Merge pull request #51808 from koic/suppress_rubocop_output_when_code_generation
Suppress RuboCop output when there are no offenses in code generation
2024-05-13 12:19:28 -04:00
Yasuo Honda d2cf718093
Merge pull request #51806 from yahonda/follow_up_51571
Use `foreign_key` option for destroy_async test models
2024-05-13 22:18:31 +09:00
Yasuo Honda 9a77052dee Use `foreign_key` option for destroy_async test models
This pull request replaces the deprecated `query_constraints:` option with `foreign_key` for destroy_async test models.
Follow up #51571

- This commit addresses these two warnings below:

```
% bin/test test/activejob/destroy_association_async_test.rb
Using sqlite3
DEPRECATION WARNING: Setting `query_constraints:` option on `Cpk::BookDestroyAsync.has_many :chapters` is deprecated. To maintain current behavior, use the `foreign_key` option instead. (called from new at /Users/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/reflection.rb:19)
/Users/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/reflection.rb:19:in `new'
  /Users/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/reflection.rb:19:in `create'
  /Users/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/associations/builder/association.rb:50:in `create_reflection'
  /Users/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/associations/builder/association.rb:32:in `build'
  /Users/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/associations.rb:1531:in `has_many'
  /Users/yahonda/src/github.com/rails/rails/activerecord/test/models/cpk/book_destroy_async.rb:7:in `<class:BookDestroyAsync>'
  /Users/yahonda/src/github.com/rails/rails/activerecord/test/models/cpk/book_destroy_async.rb:4:in `<module:Cpk>'
  /Users/yahonda/src/github.com/rails/rails/activerecord/test/models/cpk/book_destroy_async.rb:3:in `<top (required)>'
  /Users/yahonda/.rbenv/versions/3.3.1/lib/ruby/3.3.0/bundled_gems.rb:74:in `require'
  /Users/yahonda/.rbenv/versions/3.3.1/lib/ruby/3.3.0/bundled_gems.rb:74:in `block (2 levels) in replace_require'
  /Users/yahonda/src/github.com/rails/rails/activerecord/test/activejob/destroy_association_async_test.rb:27:in `<top (required)>'
  /Users/yahonda/.rbenv/versions/3.3.1/lib/ruby/3.3.0/bundled_gems.rb:74:in `require'
  /Users/yahonda/.rbenv/versions/3.3.1/lib/ruby/3.3.0/bundled_gems.rb:74:in `block (2 levels) in replace_require'
  /Users/yahonda/src/github.com/rails/rails/railties/lib/rails/test_unit/runner.rb:61:in `block in load_tests'
  /Users/yahonda/src/github.com/rails/rails/railties/lib/rails/test_unit/runner.rb:60:in `each'
  /Users/yahonda/src/github.com/rails/rails/railties/lib/rails/test_unit/runner.rb:60:in `load_tests'
  /Users/yahonda/src/github.com/rails/rails/railties/lib/rails/test_unit/runner.rb:52:in `run'
  /Users/yahonda/src/github.com/rails/rails/activerecord/test/support/tools.rb:37:in `<top (required)>'
  bin/test:11:in `require_relative'
  bin/test:11:in `<main>'
DEPRECATION WARNING: Setting `query_constraints:` option on `Cpk::ChapterDestroyAsync.belongs_to :book` is deprecated. To maintain current behavior, use the `foreign_key` option instead. (called from new at /Users/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/reflection.rb:19)
/Users/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/reflection.rb:19:in `new'
  /Users/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/reflection.rb:19:in `create'
  /Users/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/associations/builder/association.rb:50:in `create_reflection'
  /Users/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/associations/builder/association.rb:32:in `build'
  /Users/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/associations.rb:1910:in `belongs_to'
  /Users/yahonda/src/github.com/rails/rails/activerecord/test/models/cpk/chapter_destroy_async.rb:8:in `<class:ChapterDestroyAsync>'
  /Users/yahonda/src/github.com/rails/rails/activerecord/test/models/cpk/chapter_destroy_async.rb:4:in `<module:Cpk>'
  /Users/yahonda/src/github.com/rails/rails/activerecord/test/models/cpk/chapter_destroy_async.rb:3:in `<top (required)>'
  /Users/yahonda/.rbenv/versions/3.3.1/lib/ruby/3.3.0/bundled_gems.rb:74:in `require'
  /Users/yahonda/.rbenv/versions/3.3.1/lib/ruby/3.3.0/bundled_gems.rb:74:in `block (2 levels) in replace_require'
  /Users/yahonda/src/github.com/rails/rails/activerecord/test/activejob/destroy_association_async_test.rb:28:in `<top (required)>'
  /Users/yahonda/.rbenv/versions/3.3.1/lib/ruby/3.3.0/bundled_gems.rb:74:in `require'
  /Users/yahonda/.rbenv/versions/3.3.1/lib/ruby/3.3.0/bundled_gems.rb:74:in `block (2 levels) in replace_require'
  /Users/yahonda/src/github.com/rails/rails/railties/lib/rails/test_unit/runner.rb:61:in `block in load_tests'
  /Users/yahonda/src/github.com/rails/rails/railties/lib/rails/test_unit/runner.rb:60:in `each'
  /Users/yahonda/src/github.com/rails/rails/railties/lib/rails/test_unit/runner.rb:60:in `load_tests'
  /Users/yahonda/src/github.com/rails/rails/railties/lib/rails/test_unit/runner.rb:52:in `run'
  /Users/yahonda/src/github.com/rails/rails/activerecord/test/support/tools.rb:37:in `<top (required)>'
  bin/test:11:in `require_relative'
  bin/test:11:in `<main>'
Run options: --seed 24461

....................

Finished in 0.199597s, 100.2019 runs/s, 370.7471 assertions/s.
20 runs, 74 assertions, 0 failures, 0 errors, 0 skips
%
```
2024-05-13 21:55:43 +09:00
Koichi ITO 6afc3682ae Suppress RuboCop output when there are no offenses in code generation
Follow up #51782.

> But it's overkill for the default case where people use the default style guide,
> and it introduces both delay and console output as a cost.

When there are no offenses with the coding style generated by code generation,
outputting RuboCop results to the console was redundant.
Since RuboCop has `--format=quiet` option that suppresses console output
when there are no offenses, this PR adds that option:
https://docs.rubocop.org/rubocop/1.63/formatters.html#quiet-formatter

While this PR doesn't resolve any added execution speed by RuboCop,
the frequency of using the generator is not high within the development flow.
Therefore, depending on the execution speed, it might be possible to uncomment #51782,
but this PR respects the defaults in #51782 and doesn't address that.
2024-05-13 19:47:12 +09:00
Jean Boussier dae4867b33
Merge pull request #51805 from Shopify/refactor-ar-peristence-relation-methods 2024-05-13 16:27:32 +09:00
Jean Boussier ed2c15b524 Move `ActiveRecord::Base.insert` in `Relation`
Ref: https://github.com/rails/rails/pull/50396

As well as related methods.
2024-05-13 15:52:02 +09:00
Jean Boussier 8f419e482b Move `ActiveRecord::Base.destroy` in `Relation`
Ref: https://github.com/rails/rails/pull/50396
2024-05-13 15:52:02 +09:00
Jean Boussier 5e1d07dff4 Move `ActiveRecord::Base.delete` in `Relation`
Ref: https://github.com/rails/rails/pull/50396
2024-05-13 15:52:02 +09:00
Jean Boussier 135af7ba28
Merge pull request #51803 from akhilgkrishnan/fix-batch-test
Fix: batch test assertion order
2024-05-13 15:21:37 +09:00
zzak 833c1c9a4d
Enable Lint/Debugger
This will prevent issues like be0cb4e8f9, which would have resulted in:

```
guides/rails_guides/generator.rb:16:1: W: Lint/Debugger: Remove debugger entry point require "debug".
require "debug"
^^^^^^^^^^^^^^^
```

Disabled the cop in actionpack tests for screenshot_helper and page_dump_helper:

```
actionpack/test/controller/integration_test.rb:1369:9: W: Lint/Debugger: Remove debugger entry point save_and_open_page.
        save_and_open_page
        ^^^^^^^^^^^^^^^^^^
actionpack/test/controller/integration_test.rb:1381:11: W: Lint/Debugger: Remove debugger entry point save_and_open_page.
          save_and_open_page
          ^^^^^^^^^^^^^^^^^^
actionpack/test/controller/integration_test.rb:1391:39: W: Lint/Debugger: Remove debugger entry point save_and_open_page.
      assert_raise(InvalidResponse) { save_and_open_page }
                                      ^^^^^^^^^^^^^^^^^^
```

```
actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb:111:13: W: Lint/Debugger: Remove debugger entry point page.save_page(absolute_html_path).
            page.save_page(absolute_html_path)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb:115:13: W: Lint/Debugger: Remove debugger entry point page.save_screenshot(absolute_image
_path).
            page.save_screenshot(absolute_image_path)
```

The DebuggerRequires option was first available in rubocop v1.63.0, in rubocop/rubocop#12766.
2024-05-13 13:41:18 +09:00
Akhil G Krishnan 75bdf05d87 Fix: batch test assertion order
Co-authored-by: Chedli Bourguiba <chaadow@users.noreply.github.com>
2024-05-13 08:10:51 +05:30
Jean Boussier ad0e3123e1
Merge pull request #51801 from Shopify/refactor-find_by_token_for 2024-05-13 11:38:12 +09:00
Jean Boussier c08c2efda2 Refactor `ActiveRecord::TokenFor` to not rely on relation delegation
Ref: https://github.com/rails/rails/pull/50396
Ref: https://github.com/rails/rails/pull/51776

`ActiveRecord::Relation` automatically delegates missing methods
to the model class wrapped in a `scoping { }` block.

This is to support scoping in user defined class methods. The problem
however is that it's very error prone for the framework, because we
can mistakenly call model methods from inside `Relation` and not
realized we're applying a global scope.

In the best case scenario it's just a waste of performance, but
it can also lead to bugs like https://github.com/rails/rails/issues/51775

I'm planning to restrict this automatic delegation to methods defined
in childs of `ActiveRecord::Base` only: https://github.com/rails/rails/pull/50396
but for this to work we must first refactor any Rails code that rely on it.
2024-05-13 11:28:15 +09:00
Jean Boussier 41888b1c79
Merge pull request #51800 from Shopify/refactor-find_signed 2024-05-13 11:27:35 +09:00
Rafael Mendonça França 77909f38be
Do not trigger devcontainer tests on pull requests
We need to review the code before executing this workflow, so only trigger when someone merge to this repository.
2024-05-12 22:12:09 -04:00
Jean Boussier c6d0ef5974 Refactor `ActiveRecord::SignedId` to not rely on relation delegation
Ref: https://github.com/rails/rails/pull/50396
Ref: https://github.com/rails/rails/pull/51776

`ActiveRecord::Relation` automatically delegates missing methods
to the model class wrapped in a `scoping { }` block.

This is to support scoping in user defined class methods. The problem
however is that it's very error prone for the framework, because we
can mistakenly call model methods from inside `Relation` and not
realized we're applying a global scope.

In the best case scenario it's just a waste of performance, but
it can also lead to bugs like https://github.com/rails/rails/issues/51775

I'm planning to restrict this automatic delegation to methods defined
in childs of `ActiveRecord::Base` only: https://github.com/rails/rails/pull/50396
but for this to work we must first refactor any Rails code that rely on it.
2024-05-13 11:07:01 +09:00
Jean Boussier 007a609ef2
Merge pull request #51785 from fatkodima/touch_all-in-batches
Support `touch_all` in batches
2024-05-13 09:24:13 +09:00
fatkodima e057037c72 Support `touch_all` in batches 2024-05-13 09:23:57 +09:00
Gannon McGibbon e97db3b395
Merge pull request #51614 from gmcgibbon/defer_route_drawing
Defer route drawing to the first request, or when url_helpers called
2024-05-12 10:17:57 -04:00
Jean Boussier a27a1751cf
Merge pull request #51794 from sampatbadhe/patch-14
Correct typo in activerecord changelog [ci skip]
2024-05-12 15:38:30 +09:00
Sampat Badhe a44fbb11a3
Correct typo in activerecord changelog [ci skip]
Correct typo in activerecord changelog for -https://github.com/rails/rails/pull/50662
2024-05-12 10:43:00 +05:30