Commit Graph

84598 Commits

Author SHA1 Message Date
Petrik ed81962978 Add description of breaking changes and the deprecation cycle to guides.
The deprecation cycle can be confusing to contributors. We can add it to
the guide to help contributors.

Inspired by: b4fffc3c68 which already added some great
documentation.

Co-authored-by: Adrianna Chang <adrianna.chang@shopify.com>
2022-08-17 21:59:31 +02:00
Jonathan Hefner 18f8c6ac9b Add CHANGELOG entry for #45670 [ci-skip] 2022-08-17 11:51:31 -05:00
Eileen M. Uchitelle a1b2df324b
Merge pull request #45835 from eileencodes/raise-error-for-legacy-connection-handling-in-config
Define and raise error if `legacy_connection_handling=` is called from an app
2022-08-16 17:42:21 -04:00
Rafael Mendonça França 06dc8b10d7
Merge pull request #45836 from iancanderson/reduce-allocs-xml-name-escape
Reduce String allocations in `xml_name_escape`
2022-08-16 17:50:20 -03:00
eileencodes 2efb06d1dd
Define and raise error if `legacy_connection_handling=` is called from an app
I deprecated `legacy_connection_handling` setter in 7.0 but then removed
it without setting it to false by default upgraded apps might have this
set to false in their config and still be getting an error. This
confusing behavior came up with one of our apps at work.

To make it less confusing I've redefined `legacy_connection_handling`
setter and am raising an argument error if called. I didn't redefine the
getter because that shouldn't be in a config, it's not useful in that
context.
2022-08-16 16:28:00 -04:00
Ian C. Anderson b8191db909 Reduce Striing allocations in `xml_name_escape`
When working in a large rails app, I noticed in a flamegraph of a particular request that ~68ms was spent in the `xml_name_escape` method. I also ran an allocation tracer, which showed this method at the top of the list for String allocations.

This patch updates this method to avoid 3 String allocations:
- 2 allocations saved by using gsub! instead of gsub
- 1 allocation saved by concatenating to an existing string instead of allocating a new output string

For a rough benchmark in our rails app, I wrote a test with an allocation tracer around rendering a small view component.
- 244 String allocations before this change
- 228 String allocations from switching to gsub!
- 220 String allocations with this full patch

A ~10% reduction in String allocations in a real-world example seemed like a good justification for this small change.
2022-08-16 20:27:25 +00:00
Rafael Mendonça França 893e5e25e5
Merge pull request #45833 from nvasilevski/render-bad-request-on-rack-EOFError
Rescue EOFError error from rack on a multipart request
2022-08-16 11:33:37 -03:00
Nikita Vasilevsky 3b0d8c1ff0 Rescue EOFError error from rack on a multipart request 2022-08-15 23:51:13 +00:00
Jonathan Hefner d6973d50d0
Merge pull request #45670 from fatkodima/fix-in_order_of-with-nil
Fix `ActiveRecord::QueryMethods#in_order_of` to work with nils
2022-08-15 13:15:51 -05:00
fatkodima 885c024f70 Fix `ActiveRecord::QueryMethods#in_order_of` to work with nils
When passing `nil` to `in_order_of`, the invalid SQL query is generated (because `NULL != NULL`):

```ruby
Book.in_order_of(:format, ["hardcover", "ebook", nil]).to_sql
```

```sql
SELECT "books".* FROM "books" WHERE "books"."format" IN ('hardcover', 'ebook', NULL)
ORDER BY CASE "books"."format" WHEN 'hardcover' THEN 1
WHEN 'ebook' THEN 2 WHEN NULL THEN 3 ELSE 4 END ASC
```

This PR also removes the special order field generation (`ORDER BY FIELD`) for MYSQL, because it is
unable to work with `NULL`s and the default `ORDER BY CASE` works for it (tested on MariaDB and MySQL 5.7+).
2022-08-15 19:07:55 +03:00
Matthew Draper cb5765a127 Merge pull request #44472 from camertron/content_injection_prevention
Add additional content injection prevention to form HTML
2022-08-15 16:39:10 +09:30
John Hawthorn 08af60e01d
Merge pull request #45807 from ahoglund/binary-collation-fix-2
Run DROP DEFAULT for NULL value; Add text type checks
2022-08-12 13:55:55 -07:00
Jonathan Hefner 66d8f8c14d
Merge pull request #45779 from jonathanhefner/guide-form_helpers-explicitly-mention-associations
Mention associations in Form Helpers guide [ci-skip]
2022-08-12 15:44:00 -05:00
Jonathan Hefner a3a42f65e2 Mention associations in Form Helpers guide [ci-skip]
This fleshes out the "Choices from a Collection of Complex Objects"
section a bit more, explicitly mentioning associations and proper field
naming.
2022-08-12 15:36:50 -05:00
Eileen M. Uchitelle 18da7b6ba7
Merge pull request #45806 from adrianna-chang-shopify/ac-expose-schema-creation-objects
Expose `#schema_creation` methods
2022-08-12 12:06:23 -04:00
Jean Boussier bd19d1baf1 Optimize AS::LogSubscriber
The various LogSubscriber subclasses tend to subscribe to events
but then end up doing nothing if the log level is high enough.

But even if we end up not logging, we have to go through the
entire notification path, record timing etc.

By allowing subscribers to dynamically bail out early, we can
save a lot of work if all subscribers are silenced.
2022-08-12 09:58:17 +02:00
Yasuo Honda 0c212836bc
Merge pull request #45723 from ilianah/optimize_add_timestamps
Optimize add_timestamps to use a single SQL statement when supported
2022-08-12 10:30:04 +09:00
Andrew Hoglund 008d9d165a
Run DROP DEFAULT for NULL value; Add text type checks
This commit does two things.

1. Reverts a recent change that was calling SET DEFAULT NULL
when altering a table. This PR revert that back to instead call DROP
DEFAULT in the case when the column is not nullable.
2. Adds a check to ensure that only nonbinary data types are eligible
for having the `collation` carry through when performing a change_column
migration.
2022-08-11 20:16:17 +00:00
Iliana Hadzhiatanasova 79096618f0 Optimize add_timestamps to use a single SQL statement 2022-08-11 19:12:03 +03:00
fatkodima ead8558129 Make `check_constraint_exists?` public 2022-08-11 16:52:09 +03:00
Rafael Mendonça França 63d4f99e2b
Merge pull request #45631 from fatkodima/rubocop-enable-redundant-condition
Enable `Style/RedundantCondition` cop
2022-08-11 10:22:24 -03:00
fatkodima 86519996f9 Enable `Style/RedundantCondition` cop 2022-08-11 11:38:14 +03:00
Jonathan Hefner e8f189b1cb Improve ActiveSupport::ErrorReporter API doc [ci-skip]
This moves some of the documentation from the `ErrorReporter` class
directly to the `handle` and `record` methods, and fleshes those out.
This also tweaks the documentation of the other `ErrorReporter` methods.
2022-08-10 19:08:01 -05:00
Jonathan Hefner 4b784710c8
Merge pull request #45786 from shalvah/patch-1
Docs: Update ErrorSubscriber signature [ci-skip]
2022-08-10 19:06:50 -05:00
Shalvah dd80ab07a8 Update ErrorSubscriber signature
Document `severity` argument.

Change union types syntax; add docs

Trim line

Fix trailing whitespace

Co-authored-by: Hartley McGuire <skipkayhil@gmail.com>
2022-08-10 19:04:55 -05:00
Rafael Mendonça França c8668d3f16
Merge pull request #44614 from voracious/add-renderable-to-render-error-message
Add :renderable to the list of rendering keys supported by ActionView::Renderer#render
2022-08-10 19:18:11 -03:00
Rafael Mendonça França aa0952d349
Merge pull request #45412 from skipkayhil/fix-actiontext-js-main
Fix actiontext js not pointing to compiled file
2022-08-10 19:11:48 -03:00
Adrianna Chang be83bf4dee Expose #schema_creation methods
Accessing SchemaCreation instances allows consumers to visit schema definitions
and produce DDL / populate the definitions with DDL type information.
2022-08-10 14:15:14 -04:00
Jonathan Hefner c6778debcd Fix broken link [ci-skip]
Follow-up to #45752.
2022-08-10 12:45:52 -05:00
Jonathan Hefner 542d3f11fe Improve use_big_decimal_serializer documentation
Follow-up to #45618.

This fixes a few typos and clarifies the wording.
2022-08-10 12:45:52 -05:00
Rafael Mendonça França 9f1b632c4b
Merge pull request #45802 from EduardoGHdez/docs/belongs-to-default
[ci-skip] Docs: Update belongs_to [:default] option section
2022-08-10 11:33:03 -03:00
Jean Boussier a393e0de09
Merge pull request #43755 from djfpaagman/log_route_redirects
Log redirects from router similarly to controller redirects
2022-08-10 13:54:58 +02:00
Dennis Paagman ee4700241e
Log redirects from router similarly to controller redirects 2022-08-10 12:00:16 +02:00
Eduardo Hernandez c619cec014 Docs: Update belongs_to [:default] option section
Just added some more details about how `belongs_to` behaves when using
this option based on what I found here:

- https://github.com/rails/rails/blob/main/activerecord/lib/active_record/associations/builder/belongs_to.rb#L102-L106
- https://github.com/rails/rails/blob/main/activerecord/lib/active_record/associations/belongs_to_association.rb#L35-L37
2022-08-09 21:27:46 -05:00
Jean Boussier 9b138decf5
Merge pull request #45792 from ahoglund/ahoglund/binary-collation-fix
Ensure collation is set to database default when changing column to binary
2022-08-10 01:20:14 +02:00
Jonathan Hefner 95fa021465
Merge pull request #45719 from bensheldon/subpath_engine_route_helpers
Allow Mounted Engine url_helpers to use config.relative_url_root
2022-08-09 14:49:39 -05:00
Rafael Mendonça França b8868d6498
Merge pull request #44753 from ghousemohamed/extend-reserved-keywords-list-in-module-delegation
Extends ruby reserved keywords list in Module ext in Active Support
2022-08-09 16:20:45 -03:00
Rafael Mendonça França 95066e5fbd
Merge pull request #31595 from fatkodima/mailer-preview_paths
Support multiple preview paths for mailers
2022-08-09 16:20:18 -03:00
Andrew Hoglund be0a58b6c4 Ensure collation is set to database default when changing column
A recent change made it so that when you perform a change column
it will preserve collation on the column rather than nil it out·
which would select the database default. This works fine except in
the case of a binary type. In this case the collation should be
set to nil in the options so that the database default collation
type can be used on the column.
2022-08-09 17:42:18 +00:00
Ben Sheldon [he/him] 066ce1e34f
Allow Engine url_helpers to respect config.relative_url_root 2022-08-09 10:06:21 -07:00
Tom Rossi 22a0692a59
Improvements to `assert_enqueued_email_with` (#45752)
* This is an attempt to make the assert_enqueued_email_with easier to implement.

* Update actionmailer/test/test_helper_test.rb

Fix spelling.

* Documenting additional tests

* Missing a closing "end"

* Renaming tests for consistency

* Updating name

* Naming and documentation

* Leaving original test unchanged

* Fix test name, add new test

* Add assert_enqueued_emails examples to Rails guide

* Add example to test_helper

* Tweaking the Rails guide (#3)

* Updating Rails guide for consistency.

Co-authored-by: Bry <bryan.hunt@hey.com>
Co-authored-by: Ron Shinall <81988008+ron-shinall@users.noreply.github.com>
2022-08-09 14:16:19 +02:00
Jean Boussier 8994f09dd2
Merge pull request #44616 from ghiculescu/preload-all-if-proc
Always preload if using proc with multifetch cache
2022-08-09 09:01:30 +02:00
Jean Boussier 82bab92cfe
Merge pull request #45782 from fatkodima/etag_with_flash-no-flash
Fix `EtagWithFlash` when there is no Flash middleware available
2022-08-08 15:46:41 +02:00
Eileen M. Uchitelle 67ab4c3883
Merge pull request #45788 from Erol/fix-reject-unauthorized-connection-description
Correct the description for reject_unauthorized_connection
2022-08-08 08:46:35 -04:00
Eileen M. Uchitelle c54b26d90c
Merge pull request #45772 from adrianna-chang-shopify/ac-remove-ddl-from-schema-definitions
Don't store `ddl` on schema definitions
2022-08-08 08:45:20 -04:00
Adrianna Chang 47141261c3 Don't store ddl on schema definitions
We'll ensure that any consumers that require ddl obtain it by visiting
the schema definition. Consequently, we should also stop visiting the
schema definition in the "schema definition builder" methods -- callers
will need to both build a schema definition, and then visit it using a
SchemaCreation object. This means schema definitions will not be populated
with SQL type information, or any other information that is set when
the definition is visited.
2022-08-08 08:12:24 -04:00
Jean Boussier 8b0499aa1d Fix typo in ActionView::OutputBuffer
Fix: #45789

I shouldn't commit this early -_-
2022-08-08 09:53:03 +02:00
Jean Boussier dbab46008b
Merge pull request #45789 from Shopify/action-view-buffer-concat
Add ActionView::OutputBuffer#concat back
2022-08-08 09:05:44 +02:00
Jean Boussier aa0cb6d29a Add ActionView::OutputBuffer#concat back
Fix: https://github.com/rails/rails/issues/45777

The method is being used by HAML, it's easy to add it
back.
2022-08-08 09:04:27 +02:00
Erol Fornoles 69c8b6b3d1
Correct the description for reject_unauthorized_connection 2022-08-08 09:23:01 +08:00