Commit Graph

91562 Commits

Author SHA1 Message Date
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
David Heinemeier Hansson 462e914318 Show how to use the Dockerfile directly 2024-05-11 17:40:13 -07:00
David Heinemeier Hansson d539810ac5
Remove package litter after each install to shrink layer sizes (#51792)
* Remove package litter after each install to shrink layer sizes

* Need a refresh on the index when the cache is gone
2024-05-11 17:39:38 -07:00
Jean Boussier 3af5c07ecf
Merge pull request #51779 from andyw8/andyw8/fix-rubocop-autocorrect-for-windows
Fix RuboCop autocorrect for Windows compatibility
2024-05-12 08:23:38 +09:00
Andy Waite 99924b6ef2 Fix RuboCop autocorrect for Windows 2024-05-12 08:23:16 +09:00
David Heinemeier Hansson 990432f2ea
This isnt needed as a default (#51782) 2024-05-11 08:52:26 -07:00
Carlos Antonio da Silva 77f08225d1
Merge pull request #51790 from fatkodima/create_schema-if_not_exists
Add support for `:if_not_exists` and `:force` options to `create_schema`
2024-05-11 11:21:42 -03:00
fatkodima 47f25b268a Add support for `:if_not_exists` and `:force` options to `create_schema` 2024-05-11 16:40:20 +03:00
Rafael Mendonça França be0cb4e8f9
Remove debug require from guides generator 2024-05-10 18:42:55 +00:00
Rafael Mendonça França 0eed7c4ee4
Merge pull request #51637 from Shopify/update-docs-for-devcontainer
Update Getting Start With Rails guide to account for Dev Containers
2024-05-10 15:36:35 -03:00
Carlos Antonio da Silva 2744b74216
Merge pull request #51777 from eval/patch-3
`ActionController::Parameters#extract_value` example requires delimiter

[ci skip]
2024-05-10 09:49:37 -03:00
Gert Goet 111b6ab1fb
Example requires delimiter 2024-05-10 12:40:35 +02:00
Jean Boussier f8537e99c4
Merge pull request #51776 from Shopify/missing-klass-delegation
Fix `.with_connection` to not set current scope
2024-05-10 10:20:13 +02:00
Jean Boussier 4bd4fcc85d Fix `.with_connection` to not set current scope
Fix: https://github.com/rails/rails/issues/51775

This us us being bitten by https://github.com/rails/rails/pull/50396
once more. We should really make this delegation much stricter.
2024-05-10 10:02:05 +02:00
Aaron Patterson 735da84034
Merge pull request #48727 from lulalala/24390-fix-3
Fix index_errors and provide :nested_attributes_order mode
2024-05-09 12:28:34 -04:00
lulalala 1c26a39f15 Fix test
It seems now attribute being base should always be part of the key
2024-05-09 23:45:29 +08:00
Carlos Antonio da Silva bc6b432d31
Merge pull request #51504 from MooseCowBear/navigation-highlight
Add navbar highlighting to guides when scrolling [ci skip]
2024-05-09 10:26:05 -03:00
Jean Boussier 80fa11246e
Merge pull request #48585 from ghiculescu/active-job-test-adapter
Active Job: Correctly use the desired test adapter in tests
2024-05-09 14:29:30 +02:00
lulalala 0a36c36dd8 Add index_errors: :nested_attributes_order mode
which respects reject_if and is in nested_attributes order.

When in default index_errors:true mode,
fix #24390 and return index based on full association order.
2024-05-09 20:03:53 +08:00
Alex Ghiculescu 2194a738c7 Active Job: Correctly use the desired test adapter in tests 2024-05-09 17:35:50 +10:00
Gannon McGibbon e54f869e43 Defer route drawing to the first request, or when url_helpers called.
Executes the first routes reload in middleware, or when the route set
url_helpers is called. Previously, this was executed unconditionally on
boot, which can slow down boot time unnecessarily for larger apps with
lots of routes.
2024-05-08 23:43:06 -04:00
Jean Boussier 25f22503af
Merge pull request #51770 from Shopify/gc-time
Replace allocations count by GC time in request logs
2024-05-08 23:36:02 +02:00
Jean Boussier 06d3b358df Replace allocations count by GC time in request logs
Allocations count is often an interesting proxy for performance,
but not necessarily the most relevant thing to include in request
logs, given they aren't a per thread metric, so the reporting
is widely innacurate in multi-threaded environments.

Since Ruby 3.1 there is now `GC.total_time` which is a monotonically
increasing counter of time spent in GC. It still isn't really a per
thread metric, but is is more interesting because it uses the same
unit as the response time, allowing to better see when you have a GC
pause performance issue.
2024-05-08 23:02:35 +02:00
Eileen M. Uchitelle 07e40ea316
Merge pull request #51571 from Shopify/deprecate-explicit-query-constraints-in-favor-of-foreign-key
Warn about changing `query_constraints:` behavior
2024-05-08 16:22:48 -04:00
Nikita Vasilevsky 9cadf61835
Warn about changing `query_constraints:` behavior
This commit adds a deprecation warning for the `query_constraints:`
association option. This option will change behavior in the future versions
of Rails and applications are encouraged to switch to `foreign_key:` to preserve the
current behavior.
2024-05-08 20:08:09 +00:00
Rafael Mendonça França dcfabdbe4e
Merge pull request #51760 from Shopify/backward-compatibility-for-rails-console-extension
Keep Rails::ConsoleMethods's module inclusion to IRB but raise deprecation warning
2024-05-07 15:38:16 -03:00
Stan Lo 484c026f98
Continue including Rails::ConsoleMethods to IRB's internal
Due to some users/libs relying on Rails::ConsoleMethod to extend Rails
console, we need to keep including it to IRB's internal.

But to prevent also adding `app` and `helper` methods to the console,
which are already registered to IRB through its API, we need to remove
them from the Rails::ConsoleMethods. Additionally, we should raise
deprecation warning when users try to use Rails::ConsoleMethods in this
way.

This commit:
- Removes all methods from Rails::ConsoleMethods that are already
  registered to IRB. So it's now essentially empty.
- Raises a deprecation warning when modules are included to Rails::ConsoleMethods
  or methods are added to it.
- Adds a test to ensure that the deprecation warning is raised and the
  methods are available in the console.
2024-05-07 18:55:24 +01:00
Rafael Mendonça França 6c73ee08d8
Merge pull request #51749 from Shopify/devcontainer-use-sqlite-feature
SQLite3 feature for dev container
2024-05-07 13:04:12 -03:00
Carlos Antonio da Silva 59064f88d8 Remove extraneous array wrapping
We're already conditioning `reflection_fk` based on whether it's an
`Array` or not, so no need to wrap it in this `Array()` call since in
this block it is sure to be an `Array`.

Ref.: d7980c6b10
2024-05-07 09:54:05 -03:00
Jean Boussier d7980c6b10
Merge pull request #51754 from Shopify/replace-keys-allocations
Reduce allocations in BelongsToAssociation#replace_keys
2024-05-07 13:13:00 +02:00
Jean Boussier 06968f81b3 Reduce allocations in BelongsToAssociation#replace_keys
Using the same benchmark as in https://github.com/rails/rails/pull/51726

`replace_keys` always allocate a multiple arrays to support composite
primary keys, even though most primary keys likely aren't composite.

And even when they are, we can avoid needless allocations by not using
`Array#zip`.

This reduce allocations by 18% (8k) on that benchmark.

Before:

```
Total allocated: 4.88 MB (44495 objects)
Total retained: 4.16 MB (32043 objects)

allocated memory by file
-----------------------------------
...
 320.00 kB  activerecord/lib/active_record/associations/belongs_to_association.rb

allocated objects by file
-----------------------------------
...
      8000  activerecord/lib/active_record/associations/belongs_to_association.rb
```

After:

```
Total allocated: 4.56 MB (36495 objects)
Total retained: 4.16 MB (32041 objects)
```

NB: `belongs_to_association` doesn't show up in top files anymore
2024-05-07 12:43:17 +02:00
Xavier Noria dcbd6b0996 Revise the autoloading guide for middleware and friends 2024-05-07 06:25:02 -04:00
Jean Boussier bac70c3775
Merge pull request #51752 from Shopify/result-duplicated-column
Simplify `ActiveRecord::Result#hash_rows`
2024-05-07 12:07:01 +02:00
Jean Boussier bfd924ae15
Merge pull request #51751 from Shopify/docker-file-note
Explain that the default Dockerfile is intended for production
2024-05-07 11:57:04 +02:00
Jean Boussier 9652207c6b Simplify `ActiveRecord::Result#hash_rows`
Last big refactor was in https://github.com/rails/rails/pull/37614.
Somewhat extracted from https://github.com/rails/rails/pull/51744.

The concern about columns with the same name didn't make much sense
to me because in both code paths, the last one wins, so we can simplify
the whole methods.

Additionally by implementing `columns_index`, we have a decent template
always available.
2024-05-07 11:45:38 +02:00
Jean Boussier 15ad544dfa Explain that the default Dockerfile is intended for production
If people want to use Docker in development, they'd need a
radically different setup, and are likely much better served
by dev containers.
2024-05-07 10:16:47 +02:00
David Heinemeier Hansson e8e077dd16
Add ENV["SKIP_TEST_DATABASE_TRUNCATE"] flag to speed up multi-process test runs (#51686) 2024-05-06 17:04:01 -07:00
Andrew Novoselac 6e0b867a81 Improve db_system_change_generator_test.rb 2024-05-06 18:00:01 -04:00
Andrew Novoselac bd31917001 Devcontainer: Use SQLite3 feature.
This feature includes the dependencies needed for SQLite (previously we were getting these from lib-vips installation), and the SQLite3 client.
2024-05-06 17:51:04 -04:00
Jean Boussier 9ad3685538
Merge pull request #51628 from maniSHarma7575/51623-sqlite3-should-create-db-for-missing-parent-directories
[FIX] Sqlite3 Should create db for missing parent directories as well
2024-05-06 17:05:42 +02:00
maniSHarma7575 fd94a129d1 [FIX] Sqlite3 Should create db for missing parent directories as well 2024-05-06 16:04:20 +02:00
Jean Boussier 0a3a578801
Merge pull request #51748 from Shopify/result-column-types
Avoid allocating a column_type Hash when unnecessary
2024-05-06 14:42:40 +02:00
Jean Boussier 743763b860 Avoid allocating a column_type Hash when unnecessary
Only the Postgres provide these types, so no point allocating
a hash every time for other adapters.
2024-05-06 12:46:18 +02:00
Yasuo Honda f6fd15cb75
Merge pull request #51739 from viralpraxis/fix-read-ecrypted-secrets-deprecation-warning-quoting
Fix `config.read_encrypted_secrets` deprecation warning quoting
2024-05-06 13:22:03 +09:00
Yasuo Honda 942e05b449
Merge pull request #51667 from tompng/console_test_with_stdin_input_method
Fix console_test to make pass after IRB's behavior change
2024-05-06 12:32:22 +09:00
Yaroslav Kurbatov f36ad6ad5b
Fix config.read_encrypted_secrets deprecation warning quoting
Commit 0c76f17 deprecated `Rails::Application::Configuration#read_encrypted_secrets`
but, suprisingly, deprecation used backticks instead of normal quoting.
2024-05-05 17:39:17 +03:00
Yasuo Honda 343e781884
Merge pull request #51736 from maniSHarma7575/51689-remove-warning-from-render-test
[FIX] Remove warning for frozen string literal from the render test for action view
2024-05-05 21:52:10 +09:00
tompng 4b460411c7 Fix console_test to work with both IRB's RelineInputMethod and StdioInputMethod 2024-05-05 20:15:50 +09:00