Extracted from https://github.com/rails/rails/pull/50793
The leased connection is yielded, and for the duration of the block,
any call to `ActiveRecord::Base.connection` will yield that same connection.
This is useful to perform a few database operations without causing a
connection to be leased for the entire duration of the request or job.
Mostly extracted from: https://github.com/rails/rails/pull/50793
- Use `#adapter_name` instead of `#class::ADAPTER_NAME`
- Avoid monkey patching some connection instances
- Ignore SCHEMA queries in some asssertions
Otherwise they could linger around and leak memory if a user
checkout connections from short lived fibers or threads.
The undocumented `connection_cache_key` hook point is eliminated
because it was essentially add to allow the connection pool to
be fiber based rather than thread based, which is now supported
out of the box.
Ref: https://github.com/rails/rails/pull/50793
If we want to stop caching the checked out connections,
then we must persist the cache in the pool, and assign it
to the connection when it's checked out.
The pool become responsible for managing the cache lifecycle.
This also open the door to sharing the cache between multiple
connections, which is valuable for read replicas, etc.
This change only really make sense if we go through with no
longer caching checked out connections. Otherwise it's just
extra complexity.
This commit addresses `DEPRECATION WARNING: Defining enums with keyword arguments is deprecated and will be removed`
warning in Action Mailbox.
* Steps to reproduce
```ruby
git clone https://github.com/rails/rails
cd rails/actionmailbox
bundle install
bin/test test/unit/router_test.rb
```
* Without this commit
```
$ bin/test test/unit/router_test.rb
... snip ..
DEPRECATION WARNING: Defining enums with keyword arguments is deprecated and will be removed
in Rails 7.3. Positional arguments should be used instead:
enum :status, [:pending, :processing, :delivered, :failed, :bounced]
(called from <class:InboundEmail> at /home/yahonda/src/github.com/rails/rails/actionmailbox/app/models/action_mailbox/inbound_email.rb:31)
Run options: --seed 65254
...............
Finished in 0.230357s, 65.1163 runs/s, 108.5271 assertions/s.
15 runs, 25 assertions, 0 failures, 0 errors, 0 skips
$
```
Follow up https://github.com/rails/rails/pull/50987
Refer to https://github.com/rails/rails/pull/51037
* Deprecate config.active_record.warn_on_records_fetched_greater_than
* Review changes
Co-authored-by: Rafael Mendonça França <rafael@franca.dev>
---------
Co-authored-by: Jason Nochlin <hundredwatt@users.noreply.github.com>
Co-authored-by: Rafael Mendonça França <rafael@franca.dev>
While I was reading the Debugging Rails Applications guide, this typo
threw me off and I had to re-read it to understand the intended meaning,
so it seems like it's worth fixing.
And after digging in a little more, rewording the `path` example can add
some clarity.
Since #50715, there are cases where `ActiveJob::Arguments` is used
but not required anymore in the test environment. This could be a
test for a custom argument serializer.
One solution could be to add a require "active_job/arguments" in
all the usages, but that isn't a convention we follow in Rails.
Instead, let's register the autoload for `ActiveJob::Arguments` in
`active_job.rb` so that it's always available when needed.
Trilogy doesn't currently support prepared statements. The error that
applications would see is a `StatementInvalid` error. This doesn't quite point
you to the fact this isn't supported. So raise a more appropriate error
pointing to what to change.
- If an application has files named `*_test.rb` in the
"fixtures/files" folder, they were picked up to be loaded.
In most cases this would result in a LoadError as its likely
those files include code that can't be loaded.
Managed to reproduce Rails Nightly CI failure
at https://buildkite.com/rails/rails-nightly/builds/149#018d9052-1b2d-48fa-9d74-a39df3f3f1d6/1251-1291
This commit allows both 33 and 34 as its height because this issue is isolated
that thedifference comes from libvips and/or ruby-vips behavior differences, not Active Storage.
* Steps to reprodude
Run this test on Ubuntu 22.04. It should not reproduce on Ubuntu 23.10.
```
git clone https://github.com/rails/rails
cd rails
rm Gemfile.lock
cd activestorage
bin/test test/models/variant_test.rb -n test_resized_variation_of_WEBP_blob
```
* Expected behavior
It should pass.
* Actual behavior
It fails because the height of the thumbnail is 34.
```
$ bin/test test/models/variant_test.rb -n test_resized_variation_of_WEBP_blob
F
Failure:
ActiveStorage::VariantTest#test_resized_variation_of_WEBP_blob [test/models/variant_test.rb:125]:
Expected: 33
Actual: 34
bin/test test/models/variant_test.rb:117
```
Refer to https://github.com/libvips/ruby-vips/issues/383
Configure ActiveRecord::Encryption (ARE) on ActiveRecord::Base (AR)
loading, so that ARE configs are ready before AR models start using
`encrypts` to declare encrypted attributes.
This means that you can add ARE configurations in initializers, as long
as you don't trigger the loading of ActiveRecord::Base or your AR models
in prior initializers.
Fix: https://github.com/rails/rails/issues/51002
In the default middleware stack, the `ShowExceptions` middleware is
lower than `ActionDispatch::Execturor` and will handle most exceptions
causing `Executor` not to witness any.
Instead we need to rely on `action_dispatch.exception` being added
into the request env.