Commit Graph

91188 Commits

Author SHA1 Message Date
fatkodima
3461e0073f
Merge pull request #51498 from Uaitt/fields_for_documentation_improvements
Tweak documentation for `#fields_for` [skip ci]
2024-04-06 12:30:52 +03:00
fatkodima
2e2a3c3fa4
Merge pull request #51506 from alonsogarciapablo/patch-1
[ci skip] Update "Running EXPLAIN" section in the "Active Record Query Interface" guide
2024-04-06 12:21:16 +03:00
Pablo Alonso
46a1d7f0b2
Update active_record_querying.md 2024-04-05 23:59:53 +02:00
Matthew Draper
dbb5c4a703
Merge pull request #51497 from bensheldon/preparable-in
Allow `IN` with subselect to be preparable
2024-04-06 08:04:23 +10:30
Jean Boussier
83a1cff603
Merge pull request #51505 from p8/activejob/improve-enqueue-after-commit-changelog
Update `enqueue_after_transaction_commit` changelog [ci-skip]
2024-04-05 21:31:15 +02:00
Petrik
52f37c4d81 Update enqueue_after_transaction_commit changelog [ci-skip]
The config option accepts `:never`, `:always` and `:default`.
2024-04-05 21:26:28 +02:00
Jean Boussier
2b9366af55
Merge pull request #51503 from Shopify/record-ping-on-every-actioncable-message 2024-04-05 19:53:51 +02:00
yauhenisushkevich
2a71de9cca
Record ping on every actioncable message 2024-04-05 15:23:52 +00:00
Lorenzo Zabot
7d6c3d48cd Documentation improvement for #fields_for 2024-04-05 15:33:47 +02:00
Ben Sheldon [he/him]
2182419d81
Allow IN with subselect to be preparable 2024-04-04 21:36:39 -07:00
Jean Boussier
84c4598c93
Merge pull request #51457 from fatkodima/add-sql-queries-to-log
Add queries count to template rendering instrumentation
2024-04-04 17:38:23 +02:00
fatkodima
6369e92fbb Add queries count to template rendering instrumentation 2024-04-04 18:25:06 +03:00
Jean Boussier
58158c0f8c
Merge pull request #51478 from kmcphillips/mysql-parse-version-error
Raise named exception in `AbstractMysqlAdapter` when DB reports an invalid version
2024-04-04 17:15:45 +02:00
Jean Boussier
f613ba8f78
Merge pull request #51480 from albus522/dg/improve-vips-analyzer
Be a lot more memory efficient analyzing images with ruby-vips
2024-04-04 16:55:36 +02:00
Jean Boussier
30753c1929
Merge pull request #51489 from p8/guides/improve-enqueue-after-transaction-commit-documentation
Fix documentation for `enqueue_after_transaction_commit`
2024-04-04 16:53:22 +02:00
Jean Boussier
539fcc5d6d
Merge pull request #51491 from fatkodima/missing-ostruct-require
Add missing `ostruct` require to `http_token_authentication_test.rb`
2024-04-04 16:52:40 +02:00
Jean Boussier
6d42bf4716
Merge pull request #51492 from Shopify/arel-nary-or
Arel: make `Or` nodes "Nary" like `And`
2024-04-04 16:43:41 +02:00
Jean Boussier
9b841c1796
Merge pull request #51490 from Shopify/remove-git-source
Stop generating files with `git_source(:github)`
2024-04-04 15:30:26 +02:00
Jean Boussier
40d6385123 Stop generating files with git_source(:github)
This has been built-in in Bundler for years now, and the
builtin version is much better as it allows to point to a PR
directly.
2024-04-04 15:04:16 +02:00
Jean Boussier
bfcc13ab7c Arel: make Or nodes "Nary" like And
Fix: https://github.com/rails/rails/issues/51386

This significantly reduce the depth of the tree for large `OR`
conditions. I was initially a bit on the fence about that fix,
but given that `And` is already implemented this way, I see no
reasons not to do the same.

Amusingly, the reported repro script now makes SQLite fail:

```ruby
SQLite3::SQLException: Expression tree is too large (maximum depth 1000)
```
2024-04-04 14:59:56 +02:00
fatkodima
cac9c3e9e0 Add missing ostruct require to http_token_authentication_test.rb 2024-04-04 15:47:53 +03:00
Petrik
97e2e93f38 Fix documentation for enqueue_after_transaction_commit
Correct some grammar and update the framework defaults documentation
from use `true` and `false` to `:never` and `:default`.
2024-04-04 12:06:18 +02:00
Gannon McGibbon
d4c40b6cf9
Merge pull request #50941 from andrewn617/actionable-cli
Retry `ActionableError`s when running tests
2024-04-03 19:22:30 -05:00
Andrew Novoselac
bc9c66583e Allow Actionable Errors encountered when running tests to be retried.
If running in an interactive console, the user will be given the option to correct the error and re-run the tests.

Co-authored-by: Gannon McGibbon <gannon.mcgibbon@gmail.com>
2024-04-03 19:32:34 -04:00
Kevin McPhillips
d9995cc00c
Add test for MariaDB 5.5.5- prefix in db version parsing regex. 2024-04-03 16:38:33 -04:00
Kevin McPhillips
869d802c48
Raise a descriptive error if the MySQL adapter fails to parse the version string. 2024-04-03 16:38:33 -04:00
David Genord II
8d13216978
Be a lot more memory efficient analyzing images
Vips::Image#avg requires loading and evaluating the entire image. libvips can be a lot more efficient at retrieving the metadata we need.
2024-04-03 16:33:56 -04:00
Petrik de Heus
3d418c0551
Merge pull request #51449 from p8/guides/remove-proxy-association
Remove `proxy_association` references from guides [ci-skip]
2024-04-03 19:38:13 +02:00
Jean Boussier
a134d9166e
Merge pull request #51426 from Shopify/transaction-callbacks-2
Automatically delay Active Job enqueues to after commit
2024-04-03 16:49:04 +02:00
Jean Boussier
e922c59207 Implement Active Job enqueue_after_transaction_commit
A fairly common mistake with Rails is to enqueue a job from inside a
transaction, with a record as argumemnt, which then lead to a RecordNotFound
error when picked up by the queue.

This is even one of the arguments advanced for job runners backed by the
database such as `solid_queue`, `delayed_job` or `good_job`.

But relying on this is undesirable in my opinion as it makes the Active Job
abstraction leaky, and if in the future you need to migrate to another backend
or even just move the queue to a separate database, you may experience a lot of
race conditions of the sort.

To resolve this problem globally, we can make Active Job optionally transaction
aware, and automatically defer job queueing to `after_commit`.

Co-Authored-By: Cristian Bica <cristian.bica@gmail.com>
2024-04-03 16:32:16 +02:00
Jean Boussier
0e0da316ca
Merge pull request #51474 from Shopify/transaction-callback-3
Allow to register transaction callbacks outside of a record
2024-04-03 14:37:34 +02:00
Jean Boussier
c2df237414 Allow to register transaction callbacks outside of a record
Ref: https://github.com/rails/rails/pull/26103
Ref: https://github.com/rails/rails/pull/51426

A fairly common mistake with Rails is to enqueue a job from inside a
transaction, and a record as argumemnt, which then lead to a RecordNotFound
error when picked up by the queue.

This is even one of the arguments advanced for job runners backed by the
database such as `solid_queue`, `delayed_job` or `good_job`. But relying
on this is undesirable iin my opinion as it makes the Active Job abstraction
leaky, and if in the future you need to migrate to another backend or even
just move the queue to a separate database, you may experience a lot of race
conditions of the sort.

But more generally, being able to defer work to after the current transaction
has been a missing feature of Active Record. Right now the only way to do it
is from a model callback, and this forces moving things in Active Record
models that sometimes are better done elsewhere. Even as a self-proclaimed
"service object skeptic", I often wanted this capability over the last decade,
and I'm sure it got asked or desired by many more people.

Also there's some 3rd party gems adding this capability using monkey patches.
It's not a reason to upstream the capability, but it's a proof that there is
demand for it.

Implementation wise, this proof of concept shows that it's not really hard to
implement, even with nested multi-db transactions support.

Co-Authored-By: Cristian Bica <cristian.bica@gmail.com>
2024-04-03 14:26:10 +02:00
Jean Boussier
eac95d531d Fix the ActionRecord typo 2024-04-03 09:32:41 +02:00
Rafael Mendonça França
967fc62a94
Merge pull request #51468 from Earlopain/remove-ostruct-requires
Add `ostruct` to the gemfile
2024-04-02 16:08:51 -03:00
Jean Boussier
02f6c2913b
Merge pull request #51453 from fatkodima/active-counter-caches
Add the ability to ignore counter cache columns while they are backfilling
2024-04-02 14:04:13 +02:00
Earlopain
d902f4487e
Add ostruct to the gemfile
Ruby 3.5 will warn, 3.6 will raise.

This is a test-only dependency, framework code itself doesn't use it (enforced by RuboCop)
2024-04-02 13:09:00 +02:00
fatkodima
e79455f3d4 Add the ability to ignore counter cache columns while they are backfilling 2024-04-02 13:59:46 +03:00
Carlos Antonio da Silva
4a7c86af8f
Merge pull request #51456 from lloydk/fix-contrast
Reduce contrast of text and inline code elements [ci skip]
2024-04-01 15:45:20 -03:00
Carlos Antonio da Silva
0c1804db40 Remove guides CSS files that are generated by SCSS
They're overriding the SCSS generated files since the other assets are
copied after SCSS gets generated. Since they're generated every time
with the guides anyway, they are not meant to be saved raw. (for now, at
least)

Closes #51454

[ci skip]
2024-04-01 15:31:25 -03:00
Yasuo Honda
0033d46236
Merge pull request #51439 from CodingItWrong/libxml-ruby-fix-install-error
Bump libxml-ruby to fix build failure
2024-04-01 10:19:25 +09:00
Lloyd Kupchanko
b526f11f9d Reduce contrast of text and inline code elements.
To much contrast in dark mode can cause halation and makes
text hard to read.

The Accessible Perceptual Contrast Algorithm (APCA)[1] has
preliminary guidelines ([2]) for maximum contrast in dark mode.

The changes introduced in this PR ensure that the contrast for
text content does not exceed Lc 90 and does not exceed Lc 75 for
large text.

The background color for inline code elements was also darkened
so that there is less contrast with the surrounding text.

1. https://github.com/Myndex
2. https://github.com/Myndex/SAPC-APCA/discussions/106
2024-03-31 12:46:07 -06:00
John Athayde
ee4a371645
Guides Dark Mode fixes (#51444)
* Guides feedback fixes

@claudioduarte in https://github.com/rails/rails/discussions/51415

- [x] Make alt, shorter SVG line for mobile, add responsive style
- [x] Add side padding on footer (goes to edge on mobile, does not align on desktop)
- [x] Shrink overall height of subCol so it doesn’t overlap footer

@ivanjuric in https://github.com/rails/rails/discussions/51398

- [x] Flip inverted dark modes on “more Ruby on Rails” nav bar

DHH/Core:

- [x] Darker dark mode (Github style)
- [x] Double box on WIP call out (index.html. editable?)
- [x] NavBar bottom issue clipping on some guides (pad the content?)
- [x] Rounded corners/better appearance on select form elements in header
- [x] Black border on bottom of interstitials

* Additional UI cleanup

- [x] tightening up white space, adding Rails brand HR after intro
- [x] base fontsize to 16px from 18px;
- [x] fixing some darker dark mode issues in the last commit

* Lightening syntax highlight colors
2024-03-30 19:09:38 +01:00
Hartley McGuire
0a40f6ec09
Merge pull request #51437 from CodingItWrong/js-page-typos
Typo fixes on JS page [ci skip]
2024-03-30 12:50:06 -04:00
Jean Boussier
f9c262be8e
Merge pull request #51452 from Shopify/update-inverse-of-nil
Suggest `inverse_of: nil` instead of `false`
2024-03-30 10:08:38 +01:00
Jean Boussier
d6ec8dbc48 Suggest inverse_of: nil instead of false
Followup: https://github.com/rails/rails/pull/50883
Ref: https://github.com/rails/rails/pull/50284#issuecomment-2027722175
2024-03-30 09:53:38 +01:00
Josh Justice
fba3763b8d Fix typos on Working with JS page
Co-authored-by: Hartley McGuire <skipkayhil@gmail.com>
2024-03-29 12:55:28 -04:00
Petrik
1ba328e5e2 Remove proxy_association references from guides [ci-skip]
Commit 6795a24c61b038c64abff834df86d2d2459b2b23 made `proxy_assocation`
non-public API by marking it `:nodoc`.
This change remove references to `proxy_association` from the guides.
2024-03-29 15:36:17 +01:00
Jean Boussier
a2a870a736
Merge pull request #51447 from Shopify/backtrace-cleaner-dup
Make ActiveSupport::BacktraceCleaner copy filters and silencers on dup and clone
2024-03-29 12:22:35 +01:00
Jean Boussier
cc0f0f9c44 Make ActiveSupport::BacktraceCleaner copy filters and silencers on dup and clone
Previously the copy would still share the internal silencers and filters array,
causing state to leak.
2024-03-29 12:13:32 +01:00
Josh Justice
1641f119bd Bump libxml-ruby to fix build failure
https://github.com/xml4r/libxml-ruby/issues/213
c7933a7f84
2024-03-28 15:00:17 -04:00