Commit Graph

90991 Commits

Author SHA1 Message Date
David Heinemeier Hansson 270eaa0565
Suggest puma-dev configuration in bin/setup (#51088) 2024-02-14 08:26:19 -08:00
Jean Boussier 17b0c0ce14 Improve ConnectionHandlingTest
As pointed by Carlos on the PR.
2024-02-14 14:42:26 +01:00
Jean Boussier e7217c0d23 Remove a forgotten :nodoc: 2024-02-14 14:27:27 +01:00
Jean Boussier 4c4f6d07ab
Merge pull request #51083 from Shopify/activerecord-with-connection
Add `ActiveRecord::Base.with_connection` as a shortcut
2024-02-14 14:24:03 +01:00
Achmad Chun Chun 74a532ccc3 Remove duplicate value 2024-02-14 20:19:55 +07:00
Jean Boussier 22f41a1b40 Add `ActiveRecord::Base.with_connection` as a shortcut
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.
2024-02-14 14:07:04 +01:00
Achmad Chun Chun 600fb54f21 Don't override LD_PRELOAD value if already set 2024-02-14 20:06:12 +07:00
Jean Boussier bbd2be4e99
Merge pull request #51081 from Shopify/test-cleanups
Refactor some Active Record tests
2024-02-14 13:20:25 +01:00
Jean Boussier bbf0b1f33b Refactor some Active Record tests
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
2024-02-14 12:57:29 +01:00
Jean Boussier 13c1dfe4e0
Merge pull request #50938 from Shopify/refactor-query-cache-to-pool
Refactor QueryCache to be owned by the pool
2024-02-14 11:24:08 +01:00
Jean Boussier 94fc536007 Prune dead thread from connection pool caches on reap
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.
2024-02-14 10:57:16 +01:00
Jean Boussier 85742ce529 Refactor QueryCache to be owned by the pool
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.
2024-02-14 10:57:16 +01:00
Jean Boussier cef567eb87
Merge pull request #51079 from Shopify/duplicable-tests
Update Method#duplicable? to be consistent with Ruby 3.4
2024-02-14 10:33:57 +01:00
Jean Boussier ca6995a80c Update Method#duplicable? to be consistent with Ruby 3.4
Fix: https://github.com/rails/rails/issues/51075

`Method` and `UnboundMethod` used to raise on `#dup`, but not `#clone`,
this wasn't so much a feature, but a bug.

It was fixed in https://github.com/ruby/ruby/pull/9926.
2024-02-14 09:52:55 +01:00
Yasuo Honda 9b343c2879
Merge pull request #51076 from yahonda/enum_action_mailbox
Address `Defining enums with keyword arguments` warning in Action Mai…
2024-02-14 13:53:37 +09:00
Yasuo Honda 676fe1b8eb Address `Defining enums with keyword arguments` warning in Action Mailbox
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
2024-02-14 12:13:46 +09:00
Yasuo Honda aafbf0a4a7
Merge pull request #51040 from hendrixfan/remove-rollup-option
remove unknown rollup input option breakOnWarning
2024-02-14 11:40:05 +09:00
Jason Nochlin fc9ed119c7
Deprecate config.active_record.warn_on_records_fetched_greater_than (#51007)
* 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>
2024-02-13 18:20:55 -05:00
Rafael Mendonça França f8ffd46ccc
Merge pull request #51063 from anonychun/speedup-docker-build-time
Speedup Docker Build Time
2024-02-13 18:17:05 -05:00
Rafael Mendonça França 2e4a2b7eea
Merge pull request #51068 from Edouard-chin/ec-dont-load-test-from-fixture
Don't load `*_test.rb` file from the "fixtures" folder:
2024-02-13 18:09:24 -05:00
Rafael Mendonça França a9573eaa6b
Merge pull request #51035 from rails/rm-docs-actioncable
Transform actioncable documentation to Markdown
2024-02-13 17:55:42 -05:00
John Hawthorn c730877c49
Merge pull request #51019 from jhawthorn/key-provider
Remove memoization to accept `key_provider` overridden by `with_encryption_context`
2024-02-13 13:10:38 -08:00
Mike Kasberg 72410ffc49 Fix typo in Debugging Guide [ciskip]
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.
2024-02-13 13:35:07 -07:00
Rafael Mendonça França 154f7c2181
Register autoload for ActiveJob::Arguments
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.
2024-02-13 20:34:10 +00:00
Eileen M. Uchitelle 8e20f5d3b2
Merge pull request #51072 from eileencodes/raise-error-for-trilogy-and-prepared-statements
Raise error for Trilogy when `prepared_statements` is `true`
2024-02-13 15:08:58 -05:00
eileencodes 847953dbaa
Raise error for Trilogy when `prepared_statements` is `true`
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.
2024-02-13 14:47:43 -05:00
Edouard CHIN ce9f13c97e Don't load `*_test.rb` file from the "fixtures" folder:
- 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.
2024-02-13 19:01:14 +01:00
Achmad Chun Chun bdb8a6dcf7 change from deploy to base 2024-02-13 22:19:12 +07:00
Achmad Chun Chun 78061ebfe8 speedup docker build time 2024-02-13 20:26:14 +07:00
Yasuo Honda 6e7ef7d61c
Merge pull request #51037 from fatkodima/fix-deprecated-enum-syntax-tests
Fix deprecated `enum` syntax in tests
2024-02-13 21:37:23 +09:00
Yasuo Honda ec684bbe51
Merge pull request #51060 from yahonda/workaround_thumbnail_height
Address `ActiveStorage::VariantTest#test_resized_variation_of_WEBP_blob` failure at Rails Nightly CI
2024-02-13 21:29:45 +09:00
Yasuo Honda 034398fdfe Address `ActiveStorage::VariantTest#test_resized_variation_of_WEBP_blob` failure at Rails Nightly CI
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
2024-02-13 21:04:08 +09:00
Petrik de Heus a42ca9cf14
Merge pull request #51049 from sobstel/main
[DOCS] Warn against uniqueness validator when create_or_find_by is used [ci-skip]
2024-02-13 07:45:59 +01:00
Przemek Sobstel a42eda12da doc: Warn against having uniqueness validator when create_or_find_by is used
Co-authored-by: Petrik de Heus <petrik@deheus.net>
2024-02-13 07:23:58 +01:00
zzak d850686939
Add preview_docs rake task for generating API and Guides static site 2024-02-13 13:05:49 +09:00
Yasuo Honda e4f1c8758c
Merge pull request #50962 from joshuay03/update-has-one-create-test-descriptions
Update some create `has_one` failure test descriptions
2024-02-13 10:07:04 +09:00
Eileen M. Uchitelle 631429056b
Merge pull request #50606 from maximerety/active-record-encryption-eager-load
[Fix #50604] Restore compatibility of Active Record Encryption configs with eager loading mode
2024-02-12 16:13:23 -05:00
maximerety d997c554b3
[Fix #50604] Restore compatibility of ARE configs with eager loading mode
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.
2024-02-12 17:57:56 +01:00
Jean Boussier f5910f74d4
Merge pull request #51050 from Shopify/show-exception-report-error
ActionDispatch::Executor: report errors handled by ShowExceptions
2024-02-12 17:51:02 +01:00
Jean Boussier 4067c9565a ActionDispatch::Executor: report errors handled by ShowExceptions
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.
2024-02-12 17:40:24 +01:00
Nikita Vasilevsky 19a1680c17
Fix `update_all/delete_all` on CPK model relation with join subquery 2024-02-12 16:35:59 +00:00
Jean Boussier 9940dc879d docker-entrypoint: export LD_PRELOAD
Otherwise it won't applied to the execed process.

Fix: https://github.com/rails/rails/pull/50943#issuecomment-1936443319
2024-02-12 14:15:16 +01:00
Jean Boussier a8d6d477c7
Merge pull request #50999 from Shopify/refactor-transactional-fixtures
Decouple transactional fixtures and active connections
2024-02-12 09:54:39 +01:00
Javier Aranda a60039b8dc
Document that lock_version column is integer 2024-02-11 18:19:21 +01:00
Joshua Young e61234dac7 Update create has_one failure test descriptions 2024-02-11 19:42:23 +10:00
lsglucas ca73646b4a fix: outdated cors initializer docs 2024-02-10 13:30:00 -03:00
Wolfgang Fournès 33e5ce5fce remove unknown rollup input option breakOnWarning
As seen in https://buildkite.com/rails/rails/builds/104749#018d92dc-79b9-42bc-9a8c-bbcf5681f9eb/1165-1176 breakOnWarning does not seem to be a valid option for Rollup. I cannot find in the documentation, and therefore I think it can safely be removed.
2024-02-10 14:05:39 +01:00
Xavier Noria 0f9aaa5ca9
Merge pull request #51039 from rails/update-release-notes
Update 7.0 release notes re inflections and the once autoloader
2024-02-10 12:51:56 +01:00
Xavier Noria 5876939a5a Update 7.0 release notes re inflections and the once autoloader 2024-02-10 12:42:40 +01:00
fatkodima 93884c66d5 Fix deprecated `enum` syntax in tests 2024-02-10 12:42:54 +02:00