Commit Graph

89056 Commits

Author SHA1 Message Date
Johan Stenberg 9ea1e7aa78
Update activejob/lib/active_job/exceptions.rb
Co-authored-by: Alex Ghiculescu <alex@tanda.co>
2023-09-27 08:37:12 +02:00
Johan Stenberg 09889cd4f0 Adjust method documentation for ActiveJob::Exceptions::ClassMethods#retry_on. The argument does take the initial job execution attempt into account, this is not reflected in the method documentation. 2023-09-26 20:07:18 +02:00
Rafael Mendonça França dc56140f56
Merge pull request #42429 from Flixt/fix-mysql-check-constraints-quoting
Fix duplicate escaping of quotes for check constraint expressions in MySQL schema
2023-09-26 12:34:43 -04:00
Rafael Mendonça França dcc6ad5497
Merge pull request #49370 from ghiculescu/upgrade-guide-rails-test
Upgrade guide: mention `test:prepare` enhnacements
2023-09-26 12:22:16 -04:00
Felix Tscheulin 468d3d0deb
Fix duplicate escaping of quotes for check constraint expressions in MySQL schema
Mysql automatically escapes quotes in generated check constraints expressions.
When Rails dumps the schema (into schema.rb) the generated schema also contains,
the quotes with duplicated escaping (\\\\').
To fix this, we remove the escaping, that MySQL provides from the fetched
expression.
2023-09-26 16:19:37 +00:00
Rafael Mendonça França cf44b9e3b3
Merge pull request #49272 from a5-stable/attachable-as-json
Fix as_json behavior in ActionText::Attachable
2023-09-26 12:13:32 -04:00
Rafael Mendonça França 15ccf5be96
Merge pull request #49387 from fractaledmind/ar-sqlite-7_1-release-notes
[skip ci] Add 7.1 release notes for SQLite3 adapter improvements
2023-09-26 12:03:13 -04:00
Rafael Mendonça França 5dfded9e33
Remove connection created in the test
This will avoid those connection leaking to other tests.

They cause problem because the fixtures loading will try to open
a transaction on all the active connections and since those connections
use a database pointing to a temp file that doesn't exist anymore
if any transaction try to start on them it will fail.

Fixes #49373.
2023-09-26 16:00:40 +00:00
a5-stable 7809146a03 fix ActionText::Attachable#as_json to allow options 2023-09-27 00:51:18 +09:00
Stephen Margheim 8c5584cf07 Add 7.1 release notes for SQLite3 adapter improvements 2023-09-26 16:09:05 +02:00
Eileen M. Uchitelle 05ed2610ce
Merge pull request #49386 from rails/revert-49096-document_class_method_scope_behavior
Revert "Document clean chain behavior for ActiveRecord scope"
2023-09-26 09:14:36 -04:00
zzak a564341537
Revert "Document clean chain behavior for ActiveRecord scope" 2023-09-26 20:44:22 +09:00
Ryuta Kamizono 4d42741a53 Fix typo "an unique" -> "a unique" [ci skip] 2023-09-26 19:58:49 +09:00
Ryuta Kamizono 708176efb0
Merge pull request #49383 from kamipo/rename_unique_constraint
Rename back unique keys to unique constraints
2023-09-26 18:35:14 +09:00
Ryuta Kamizono b2790b6680 Rename back unique keys to unique constraints
As we (I and @yahonda) talked about the naming in person, naming unique
constraints as unique keys is very confusing to me.
All documents and descriptions says it's unique constraints, but naming
unique keys leads to misunderstanding it's a short-hand of unique
indexes.
Just naming it unique constraints is not misleading.
2023-09-26 17:52:09 +09:00
Jess Brown c32813ddc6
Update description for filter_parameter_logging (#49347)
* Update description for filter_parameter_logging

* Update railties/lib/rails/generators/rails/app/templates/config/initializers/filter_parameter_logging.rb.tt

Thanks Rob!!. I did all this in the github ui and was a little out of sorts with the wrapping.

Co-authored-by: Rob Zolkos <rob@zolkos.com>

---------

Co-authored-by: Rob Zolkos <rob@zolkos.com>
Co-authored-by: Rafael Mendonça França <rafael@rubyonrails.org>
2023-09-25 23:21:03 -04:00
Rafael Mendonça França 92742751a9
Don't leak database connection to other tests 2023-09-26 01:59:13 +00:00
Rafael Mendonça França 3721fdce48
Remove erroneous committed file 2023-09-26 00:00:12 +00:00
Rafael Mendonça França 38ce7fa6b1
Merge pull request #48542 from ghiculescu/am-default-form-builder
Introduce `ActionMailer::FormBuilder`
2023-09-25 17:27:38 -04:00
Rafael Mendonça França 4c72cc2b04
Merge pull request #48615 from Edouard-chin/ec-logger
Add a public API for broadcasting logs
2023-09-25 17:13:58 -04:00
Rafael Mendonça França 88bb5f2749
Define the method in the right place 2023-09-25 21:04:41 +00:00
Rafael Mendonça França 4e605f5d0f
Fix ruby warning
Remove `.[]` before redefining it.
2023-09-25 20:47:36 +00:00
Edouard CHIN 1fbd812c47
Add a public API for broadcasting logs:
- ## Context

  While working on https://github.com/rails/rails/pull/44695, I
  realised that Broadcasting was still a private API, although it’s
  commonly used. Rafael mentioned that making it public would require
  some refactor because of the original implementation which was hard
  to understand and maintain.

  ### Changing how broadcasting works:

  Broadcasting in a nutshell worked by “transforming” an existing
  logger into a broadcasted one.
  The logger would then be responsible to log and format its own
  messages as well as passing the message along to other logger it
  broadcasts to.

  The problem with this approach was the following:

  - Heavy use of metaprogramming.
  - Accessing the loggers in the broadcast wasn’t possible.
    Removing a logger from the broadcast either.
  - More importantly, modifying the main logger (the one that broadcasts
    logs to the others) wasn’t possible and the main source of
    misunderstanding.

    ```ruby
      logger = Logger.new(STDOUT)
      stderr_logger = Logger.new(STDER))
      logger.extend(AS::Logger.broadcast(stderr_logger))

      logger.level = DEBUG # This modifies the level on all other loggers
      logger.formatter = … # Modified the formatter on all other loggers
    ```

  To keep the contract unchanged on what Rails.logger returns, the new
  BroadcastLogger class implement duck typing with all methods
  that has the vanilla Ruby Logger class.

  It's a simple and boring PORO that keeps an array of all the loggers
  that are part of the broadcast and iterate over whenever a log is
  sent.
  Now, users can access all loggers inside the broadcast and modify
  them on the fly. They can also remove any logger from the broadcast
  at any time.

  ```ruby
  # Before

  stdout_logger = Logger.new(STDOUT)
  stderr_logger = Logger.new(STDER)
  file_logger = Logger.new(“development.log”)
  stdout_logger.extend(AS::Logger.broadcast(stderr_logger))
  stdout_logger.extend(AS::Logger.broadcast(file_logger))

  # After

  broadcast = BroadcastLogger.new(stdout_logger, stderr_logger, file_logger)
  ```

  I also think that now, it should be more clear for users that the
  broadcast sole job is to pass everything to the whole loggers in
  the broadcast. So there should be no surprise that all loggers in
  the broadcast get their level modified when they call
  `broadcast.level = DEBUG` .

  It’s also easier to wrap your head around more complex setup such
  as broadcasting logs to another broadcast:
  `broadcast.broadcast_to(stdout_logger, other_broadcast)`
2023-09-25 20:40:51 +00:00
Alex Ghiculescu 9a2cf33f21
Introduce `ActionMailer::FormBuilder`
Fixes https://github.com/rails/rails/issues/48477

Using forms inside emails is not common, but it's possible, and it's also possible to share views between controllers and mailers. Currently if a controller sets a `default_form_builder` that's different from the global config, mailers that use the same views will not default to the same `FormBuilder`. To fix this, this PR adds a `default_form_builder` method for mailers that does the same thing as its controller sibling.
2023-09-25 20:33:22 +00:00
Rafael Mendonça França ad7a3e2d80
Merge pull request #49322 from hachi8833/add_tests_for_exclusion_validation2
[Docs][Tests] Add tests for validates_exclusion_of to 7.1.0beta1
2023-09-25 16:26:58 -04:00
Rafael Mendonça França 71613d3da9
Merge pull request #45411 from jonathanhefner/add-deep_mergeable
Factor out `deep_merge` into `AS::DeepMergeable`
2023-09-25 16:25:44 -04:00
Jean Boussier 2d196d4898
Merge pull request #49381 from dorianmariefr/fix-upload-of-files
Actually upload the files when passed as File or Pathname
2023-09-25 19:33:09 +02:00
Dorian Marié 94a7149a96 Actually upload the files when passed as File or Pathname
This is a follow-up to https://github.com/rails/rails/pull/45606

We were storing the file metadata in Blob and Attachment but we were not
actually uploading the files (into the file system for instance for disk
storage).

It was failing silently so I made it explicit what is accepted and what
is unexpected
2023-09-25 19:01:21 +02:00
Eileen M. Uchitelle f57d54cde4
Merge pull request #49336 from fatkodima/fix-mysql-expression-index-dumping
Fix MySQL expression index dumping with escaped quotes
2023-09-25 10:22:34 -06:00
Vipul A M d64e44b003
Merge pull request #49379 from akhilgkrishnan/code-highlight-fix
[skip ci] Missing language highligting added for bash code block
2023-09-25 21:47:10 +05:30
Akhil G Krishnan 14208d4d53 [skip ci] Missing language highligting added for bash code block 2023-09-25 21:25:33 +05:30
Jean Boussier adf1c2183f Fix an incorrect `assert_equal` argument order 2023-09-25 15:57:06 +02:00
Jean Boussier 94c90ecf20
Merge pull request #45606 from dorianmariefr/build-blob-from-file-or-pathname
Allow attaching File or Pathname to has_one_attached
2023-09-25 13:50:46 +02:00
Jean Boussier 99e2999f96
Merge pull request #48462 from iamradioactive/remove_additional_query
Do not revalidate encrypted attribute with current encrypted_type
2023-09-25 13:50:07 +02:00
Dorian Marié 22bacd710d Allow attaching File or Pathname to has_one_attached
### Why was this change necessary?

When creating models in tests, it's easier to pass a File or a Pathname
(from `file_fixture` for instance) to `Model.create` for instance

### How does it address the problem?

When attaching an attachable, we check if it's a File or a Pathname and
handle it appropriately.
2023-09-25 13:43:26 +02:00
Xavier Noria 44d0859904 Minor edits in the upgrading guide 2023-09-25 11:45:47 +02:00
Ryuta Kamizono e35e78020f
Merge pull request #49372 from skipkayhil/hm-rm-safe-level-requires
Update requires in LoggerThreadSafeLevel
2023-09-25 12:06:22 +09:00
Hartley McGuire 162be9f219
Merge pull request #49350 from bhanubhakta/bhanubhakta-include-hidden-file-field-docs
Update doc for `include_hidden` form form file_field.
2023-09-24 22:16:28 -04:00
Hartley McGuire 0f5e7a6614
Update requires in LoggerThreadSafeLevel
The `concurrent` require was [added][1] previously because a
`Concurrent::Map` was added to hold all of the log levels by `Thread` id.
However, the `Map` was later [removed][2] by storing the log levels in the
`Thread` locals (and later in `IsolatedExecutionState`) instead. The new
implementation additionally removed the `cattr_accessor` (removing the
need to require the "attribute_accessors" core_ext) and also replaced
the [usage][3] of `Fiber` with `Thread` (so the require for `Fiber` is also no
longer necessary).

Since `Concurrent`, `Fiber`, and `cattr_accessor` are no longer used here, we
can remove the requires. Since `Logger` is used here (but was previously
required by `concurrent`), a require was added for it.

[1]: 629efb6057
[2]: 2379bc5d2a
[3]: 56ec504db6
2023-09-24 21:59:55 -04:00
Bhanu Bhakta Sigdel 72b3fe9f09 Update doc for `include_hidden` form form file_field.
Update `include_hidden: false` to `include_hidden: true`

Update the language to be more accurate.

Update actionview/lib/action_view/helpers/form_helper.rb

Co-authored-by: Hartley McGuire <skipkayhil@gmail.com>
2023-09-24 19:44:08 -06:00
Alex 9910e37e6f Upgrade guide: mention `test:prepare` enhnacements
Fixes: https://github.com/rails/rails/issues/49363

Mentions https://github.com/rails/rails/pull/46664 in the upgrade guide.
2023-09-25 10:04:30 +10:00
Guillermo Iguaran d8391b27d4
Merge pull request #49349 from fractaledmind/ar-sqlite-tune-connection-config
Performance tune the SQLite3 adapter connection configuration
2023-09-24 14:09:47 -07:00
Stephen Margheim c6d7ffc7b8 Performance tune the SQLite3 adapter connection configuration
For Rails applications, the Write-Ahead-Log in normal syncing mode with a capped journal size, a healthy shared memory buffer and a shared cache will perform, on average, 2× better.
2023-09-24 21:34:00 +02:00
Guillermo Iguaran 7c07787a5d
Merge pull request #49352 from fractaledmind/ar-sqlite-retries
Allow SQLite3 `busy_handler` to be configured with simple max number of retries
2023-09-24 10:53:02 -07:00
Xavier Noria d99e355390 Simplify wording, avoids word wrap 2023-09-24 09:08:01 +02:00
Vipul A M 46e3076848
Merge pull request #49366 from hachi8833/fix_ar_changelog_364939c 2023-09-24 11:35:03 +05:30
hachi8833 3b028fd74e Fix: expores_in -> expires_at 2023-09-24 13:18:00 +09:00
Guillermo Iguaran 4b8cdef210
Merge pull request #49356 from skipkayhil/hm-fix-empty-range-overlap
Fix Range#overlap? ignoring empty ranges
2023-09-23 12:03:15 -07:00
Xavier Noria ef6c3fb4bf
Merge pull request #49359 from rails/upgrade-guide-autoload-lib
Add a section about config.autoload_lib(_once) to the upgrading guide
2023-09-23 20:31:11 +02:00
Xavier Noria 72bd066432 Add a section about config.autoload_lib(_once) to the upgrading guide 2023-09-23 20:15:34 +02:00