Commit Graph

90968 Commits

Author SHA1 Message Date
Jean Boussier af85f74418
Merge pull request #51174 from Shopify/connection-less-quoting
Don't require an active connection for table and column quoting
2024-02-27 11:34:32 +01:00
Jean Boussier 0016280f4f Don't require an active connection for table and column quoting
Extracted from: https://github.com/rails/rails/pull/50793

Right now quoting table or column names requires a leased Adapter
instance, even though none of the implementations actually requires
an active connection.

The idea here is to move these methods to the class so that the quoting
can be done without leasing a connection or even needing the connection
to ever have been established.

I also checked `activerecord-sqlserver-adapter` and `oracle-enhanced`
gems, and neither need an active connection.
2024-02-27 11:19:00 +01:00
Rafael Mendonça França 0a9ca0107c
✂️ 2024-02-27 02:16:02 +00:00
Rafael Mendonça França 88afcce1dd
Merge pull request #51198 from willnet/fix-wrong-documentation-for-logger_outputs_to
Fix documentation and sample code for `ActiveSupport::Logger.logger_outputs_to?`
2024-02-26 21:08:52 -05:00
Shinichi Maeshima fc62f03ae3
[ci skip]Fix documentation and sample code for `ActiveSupport::Logger.logger_outputs_to?`
Fixed incorrect documentation for `ActiveSupport::Logger.logger_outputs_to?`. The method expects the first argument to be a Logger object and subsequent variadic arguments to be either IO objects or strings representing file paths.

Also corrected the sample code in CHANGELOG.md, which previously only passed a single argument, not reflecting the correct usage.

related PR: https://github.com/rails/rails/pull/51125
2024-02-27 10:56:53 +09:00
Rafael Mendonça França a3f884f7a7
Merge pull request #50128 from thiagopradi/main
Removing not used fixtures from ActionPack test suite
2024-02-26 20:52:10 -05:00
Rafael Mendonça França ada3d775bd
Use `Kernel#Array` to wrap the default value 2024-02-27 01:37:54 +00:00
Rafael Mendonça França d216d1ede7
Do not always mark the default translation as html safe
If the `_html` suffis isn't provided we should not mark the default
translation as html safe and escape it.
2024-02-27 01:36:40 +00:00
Carlos Antonio da Silva c402ec7872 Add punctuation on some newly added API docs [ci skip] 2024-02-26 13:32:39 -03:00
Jean Boussier f0864e34d6
Merge pull request #51193 from Shopify/fix-migrator-current-version
Fix `Migrator.current_version` to instantiate `SchemaMigration` correctly
2024-02-26 12:54:26 +01:00
Jean Boussier 6e74098b8c Fix `Migrator.current_version` to instantiate `SchemaMigration` correctly
This was missed in https://github.com/rails/rails/pull/51162
2024-02-26 12:49:31 +01:00
Vipul A M 2abee307fe
Merge pull request #51184 from ConfusedVorlon/document_after_commit_deduplication
[ci skip] Add warning about deduplication of after_xxx_commit shortcuts
2024-02-25 16:30:11 -05:00
Vipul A M e34a0eec38
Merge pull request #51186 from Earlopain/encourage-html-safe-methods-for-safe-join
Docs: Encourage html safe methods for safe join [ci skip]
2024-02-25 11:58:07 -05:00
Vipul A M 4a95c64685
Merge pull request #51187 from lexcao/fix/typo
Fix typo [ci-skip]
2024-02-25 10:21:44 -05:00
Lex Cao 48036fee0d Fix typo 2024-02-25 23:11:40 +08:00
Thiago Pradi 4a91897831
Merge branch 'rails:main' into main 2024-02-25 11:37:47 -03:00
Earlopain 295e7079aa
Docs: Encourage html safe methods for safe join 2024-02-25 12:27:56 +01:00
Rob Jonson 79fa0e3b2d Add warning about deduplication of after_xxx_commit shortcuts 2024-02-24 19:40:13 +00:00
Edouard CHIN 23af6f37a3
Merge pull request #51180 from cjilbert504/patch-1
Update layouts_and_rendering.md
2024-02-24 15:19:07 +01:00
Collin Jilbert 9c01c39480
Update layouts_and_rendering.md
This PR corrects a reference to the act of renaming a partial when in fact it is a local variable that would be renamed instead.
2024-02-24 07:35:07 -06:00
Yasuo Honda 47300002db
Merge pull request #51178 from fatkodima/fix-flaky-multi_db_migrator-test
Fix flaky `multi_db_migrator_test.rb` test
2024-02-24 13:07:07 +09:00
fatkodima 5db70c979e Fix flaky `multi_db_migrator_test.rb` test 2024-02-24 02:38:31 +02:00
Rafael Mendonça França b6285e98f0
Make sure `assert_initializer` accepts a block 2024-02-23 21:54:54 +00:00
Gannon McGibbon bc7dea8c4c
Merge pull request #51173 from gmcgibbon/fix_uri_parse_redirect
Handle bad URIs when filtering redirects
2024-02-23 15:39:18 -06:00
Rafael Mendonça França 8b7e682d86
Merge pull request #51176 from stevepolitodesign/assert-initializer
Introduce `Rails::Generators::Testing::Assertions#assert_initializer`
2024-02-23 15:36:05 -05:00
Steve Polito fb16702fee Introduce `Rails::Generators::Testing::Assertions#assert_initializer`
Compliments the existing [initializer][] generator action.

```rb
assert_initializer "mail_interceptors.rb"
```

[initializer]: https://api.rubyonrails.org/classes/Rails/Generators/Actions.html#method-i-initializer
2024-02-23 10:54:25 -05:00
Jean Boussier cb47c12aa5
Merge pull request #51175 from Shopify/fixtures-connection-pool
Refactor FixtureSet to deal with connection pools
2024-02-23 11:38:08 +01:00
Jean Boussier 2cbedfdb2e Refactor FixtureSet to deal with connection pools
Extracted from: https://github.com/rails/rails/pull/50793

Allow to check the cache without checking out a connection.
2024-02-23 11:25:33 +01:00
Gannon McGibbon 61b0a68940 Handle bad URIs when filtering redirects
rails/rails#51131 introduced parameter filtering for redirects. We
didn't account for invalid URIs though, and it changes the behaviour of
redirect_to to raise URI errors when we try to filter a bad URI.
Instead, we should fallback to filtering bad URIs entirely to preserve behaviour.
2024-02-23 00:11:24 -06:00
Rafael Mendonça França 3c6adf2994
Merge pull request #51168 from Shopify/pool-reflection-assignation
ConnectionPool: handle schema_reflection being re-assigned
2024-02-22 16:28:48 -05:00
Jean Boussier 932e029ad7
ConnectionPool: handle schema_reflection being re-assigned
This fixes a regression recently introduced that a schema_reflection
assignment from taking effect.
2024-02-22 21:13:04 +00:00
Avee 6534a5d91f
[ci skip] Update ActiveStorage Docs (#51157)
* Update ActiveStorage Docs

Included documentation around usage of the `key` parameter in `.attach` method to specify folders within S3 Bucket for organizing files and storing them with intuitive names.

* Update active_storage_overview.md

lint correction - removed trailing whitespace

Co-authored-by: Rafael Mendonça França <rafael@rubyonrails.org>
2024-02-22 14:58:43 -05:00
Jean Boussier 9f1dec2ea5
Merge pull request #51162 from Shopify/refactor-internal-metadata-pool
Refactor InternalMetadata, MigrationContext to belong to the pool
2024-02-22 13:04:56 +01:00
Jean Boussier a918394974 Refactor InternalMetadata, MigrationContext to belong to the pool
Extracted from: https://github.com/rails/rails/pull/50793

Similar to the recent refactoring of schema caches, rather than to directly
hold a connection, they now hold a pool and checkout a connection when needed.
2024-02-22 12:46:41 +01:00
John Hawthorn 85c58ffa36
Merge pull request #51156 from jhawthorn/translation_exception
Respect raise_on_missing_translations in controller's translations
2024-02-21 13:46:40 -08:00
John Hawthorn 0f870c4354 Respect raise_on_missing_ in controller
Previously raise_on_missing_translations was not being respected in a
controller. This commit brings back the correct behaviour.
2024-02-21 13:18:58 -08:00
Rafael Mendonça França 939742d69e
Merge pull request #50901 from joshuay03/fix-autosave-has-one-setting-fk-when-unchanged
[Fix #50897] Autosaving `has_one` sets foreign key attribute when unchanged
2024-02-21 15:21:23 -05:00
Rafael Mendonça França 3e42d79c99
Merge pull request #51078 from saleh-alhaddad/support_join_types_in_where_associated
Fix override existing join types in the query in the `where.associated` method
2024-02-21 15:10:24 -05:00
ooooooo_q 857f2e4a6a
fix XSS vulnerability when using translation
[CVE-2024-26143]
2024-02-21 10:20:05 -08:00
Aaron Patterson a3f3c3e5d6
Fix ReDoS in accept header scanning
Thanks svalkanov for the patch!

[CVE-2024-26142]
2024-02-21 10:17:42 -08:00
saleh-alhaddad 3400aac7f9
Fix an issue in the `where.associated` method 2024-02-21 18:12:15 +00:00
Iago Pimenta 32587c3bdd
Fix inconsistent results of params.deep_transform_keys (#50361)
* Fix inconsistent results of params.deep_transform_keys

* fix: specs

* fix: implements own deep_transform methods to ActionController::Parameters

Co-authored-by: Rafael Mendonça França <rafael@rubyonrails.org>
2024-02-21 12:55:30 -05:00
mylesboone 278d6574cf
`ActiveRecord::Relation#order` supports hash like `ActiveRecord::Relation#where` (#50000)
* relation#order supports hash like relation#where

This allows for an ActiveRecord::Relation to take a hash such as
`Topic.includes(:posts).order(posts: { created_at: :desc })`

* use is_a? to support subclasses of each

Co-authored-by: Rafael Mendonça França <rafael@rubyonrails.org>
2024-02-21 12:43:15 -05:00
Rafael Mendonça França db4c6db59d
Merge pull request #32770 from zealot128/patch-2
Request Forgery takes relative paths into account
2024-02-21 12:16:54 -05:00
Eugene Kenny 7c135eda92
Merge pull request #51150 from eugeneius/lazy_load_controller_integration
Don't force controller or integration tests to load
2024-02-21 16:03:56 +00:00
Jean Boussier 684131a4f0
Merge pull request #51139 from Shopify/relation-bound-sql-literal
Relation#where build BoundSqlLiteral rather than eagerly interpolate
2024-02-21 16:49:45 +01:00
Carlos Antonio da Silva baad391196 Remove unused intermediate variable
It was necessary to return properly with the previous deprecation code,
which was removed in eccc6061f4.
2024-02-21 09:31:27 -03:00
Jean Boussier 8e6a5deca6 Relation#where build BoundSqlLiteral rather than eagerly interpolate
Ref: https://github.com/rails/rails/pull/50793

To make not caching connection checkout viable, we need to reduced
the amount of places where we need a connection.

Once big source of this is query/relation building, where in many
cases it eagerly quote and interpolation bound values in SQL fragments.

Doing this requires an active connection because both MySQL and Postgres
may quote values differently based on the connection settings.

Instead of eagerly doing all this, we can instead just insert these
as bound values in the Arel AST. For adapters with prepared statements
this is better anyway as it will avoid leaking statements, and for those
that don't support it, it will simply delay the quoting to just
before the query is executed.

However, the `%` API (`where("title = %s", something)`) can't realistically
be fixed this way, but I don't see much value in it and it probably should
be deprecated and removed.
2024-02-21 13:22:55 +01:00
Vipul A M cdc1ca7a32
Merge pull request #51153 from dzjuck/main
Fix code formatting in layouts and rendering guide [skip ci]
2024-02-21 06:08:56 -05:00
Ilya Lavrov 36a1eca3fd Fix code formatting in layouts and rendering guide 2024-02-21 12:01:02 +01:00