Commit Graph

85517 Commits

Author SHA1 Message Date
Jonathan Hefner
caaac482d5
Merge pull request #46709 from cjilbert504/belongs-to-association-changed-guide-update
update return values to reflect the proper object class [ci-skip]
2022-12-12 21:49:18 -06:00
Jonathan Hefner
ac3ab2d2ae
Merge pull request #46708 from cjilbert504/errors-where-guides-grammar
fix pluralization and punctuation issues [ci-skip]
2022-12-12 21:45:22 -06:00
Collin Jilbert
696ed4ebdd update return values to reflect the proper object class 2022-12-12 21:11:08 -06:00
Eileen M. Uchitelle
ba76451810
Merge pull request #46706 from rails/refactor-compiled-source
Refactor compiled source code into method
2022-12-12 15:59:01 -05:00
eileencodes
5026abaeb1
Refactor compiled source code into method
Moves the part of `compile!` that compiles the template source into it's
own method. We need this for future work in improving exceptions for ERB
templates to pass to ErrorHighlight.

Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
2022-12-12 15:31:19 -05:00
Jonathan Hefner
a1367da11d
Merge pull request #46678 from kryzhovnik/main
Fix Issue #46677
2022-12-12 12:06:23 -06:00
Eileen M. Uchitelle
e90bc0d9e9
Merge pull request #46694 from ghiculescu/strict-loading-on-assoc-writers
Fix: `StrictLoadingViolationError` when concatenating or setting association when non-persisted owner has primary key
2022-12-12 11:57:21 -05:00
Jonathan Hefner
8f777e3225
Merge pull request #46701 from ghiculescu/patch-10
Fix lint error in Railties changelog
2022-12-12 10:49:11 -06:00
Alex Ghiculescu
797381fc2d Fix: StrictLoadingViolationError when concatenating or setting association when non-persisted owner has primary key
Fixes https://github.com/rails/rails/issues/46689
2022-12-12 10:38:37 -06:00
Alex Ghiculescu
28ecaf6dba
Fix lint error in Railties changelog
ref: https://github.com/rails/rails/pull/46699
2022-12-12 10:27:45 -06:00
Jean Boussier
c5fb44bce4 Fix corrupted guides/source/configuring.md 2022-12-12 11:23:45 +01:00
Jean Boussier
899ed2904e Clarify that config.log_file_size expect a number of bytes 2022-12-12 10:42:36 +01:00
David Heinemeier Hansson
d18fc32999
Use storage/ instead of db/ for sqlite3 db files (#46699)
* Use storage/ instead of db/ for sqlite3 db files

db/ should be for configuration only, not data. This will make it easier to mount a single volume into a container for testing, development, and even sqlite3 in production.
2022-12-12 08:32:12 +01:00
Jonathan Hefner
16eaf44b5a
Merge pull request #46698 from yskkin/remove_columns_doc
documentation for #36589 [ci-skip]
2022-12-11 21:00:51 -06:00
Yoshiyuki Kinjo
8a1c06e9dc [ci skip] documentation for #36589 2022-12-12 08:37:28 +09:00
Andrey Samsonov
c20b629f52 Fix inconsistent behavior in form helper date/time tags with options; issue #46677
This change makes date/time options (value, min, max) in `time_field`, `date_field`, `datetime_field`, `week_field`, `month_field` form helpers behave in a unified way.
2022-12-11 17:19:18 +01:00
Jean Boussier
ef02c3a220
Merge pull request #46697 from joshuay03/improve-#ids-test-coverage
Update `ActiveRecord::Calculations#ids` and improve test coverage
2022-12-11 09:10:18 +01:00
Joshua Young
0c16feb4bc Update ActiveRecord::Calculations#ids and improve test coverage 2022-12-11 11:32:22 +05:30
Xavier Noria
01bc3a4971 Document 4 ways to preload STIs 2022-12-10 21:18:57 +01:00
Petrik de Heus
76ca38e0d1
Merge pull request #46679 from ghiculescu/action-cable-guide [ci-skip]
Clarify how to use a standalone Action Cable server
2022-12-10 12:05:21 +01:00
Rafael Mendonça França
7ebbe3251f
Merge pull request #46688 from rails/revert-46613-strict-loading-build
Revert "Fix: Strict Loading error after initializing association owner with primary key"
2022-12-09 13:27:27 -05:00
Rafael Mendonça França
3828c87855
Revert "Fix: Strict Loading error after initializing association owner with primary key" 2022-12-09 13:27:07 -05:00
Alex Ghiculescu
cd04f3bfe4 Clarify how to use a standalone Action Cable server 2022-12-09 12:17:20 -06:00
Eileen M. Uchitelle
2c86139e23
Merge pull request #46676 from Shopify/ordered-relation-respects-query-constraints
`#last` and `#first` finders should use `query_constraints` for ordering
2022-12-09 11:07:24 -05:00
Eileen M. Uchitelle
263efecc64
Merge pull request #46249 from seanpdoyle/action-text-system-test-helper-focus
Focus editor after calling `fill_in_rich_text_area`
2022-12-09 10:08:26 -05:00
Nikita Vasilevsky
16351524fa #last and #first finders should use query_constraints for ordering 2022-12-09 14:59:33 +00:00
Sean Doyle
67a4ac6c56 Focus editor after calling fill_in_rich_text_area
When System Tests call `fill_in_rich_text_area`, they interact with
`<trix-editor>` elements by changing the contents programmatically.

This is unlike how end-users will interact with the element. Overhauling
the test helper to more accurately reflect Real World usage would
require a sizable effort.

With that being said, leaving the `<trix-editor>` with focus after
populating its contents is a minor change that makes it a more genuine
recreation.
2022-12-09 09:48:27 -05:00
Eileen M. Uchitelle
59fe981e4c
Merge pull request #46683 from fatkodima/add_foreign_key-if_not_exists
Fix `add_foreign_key` with `if_not_exists` referencing the same table but via different columns
2022-12-09 09:14:50 -05:00
Eileen M. Uchitelle
f002536a5d
Merge pull request #46271 from seanpdoyle/has-rich-text-strict-loading
Support `has_rich_text` with `strict_loading:`
2022-12-09 08:44:07 -05:00
Jean Boussier
4435b7afe3
Merge pull request #46503 from joshuay03/update-calculations-ids
Fix: `ActiveRecord::Calculations#ids` returns duplicate ids
2022-12-09 12:41:32 +01:00
Jean Boussier
cc50791625 AS::Cache#fetch fully skip the read operation when force: true
It makes little sense to emit a `:read` event given we explictly
asked not to read.
2022-12-09 12:35:52 +01:00
fatkodima
cf3c04f859 Fix add_foreign_key with if_not_exists referencing the same table but via different columns 2022-12-09 12:40:41 +02:00
Jean Boussier
f04074cfa1
Merge pull request #46661 from Shopify/clear-query-cache-deadlock
Use a single lock for all connections
2022-12-09 08:27:33 +01:00
Joshua Young
8fd336927a [Fix: #46455] ActiveRecord::Calculations#ids plucks included associations IDs 2022-12-09 08:23:48 +05:30
Eileen M. Uchitelle
3e1195c299
Merge pull request #46270 from eileencodes/extract-calls-on-base-for-rake-tasks
Move calls on Base connection to methods for rake tasks
2022-12-08 16:59:42 -05:00
eileencodes
901828f2fa
Move calls on Base connection to methods for rake tasks
This PR aims to contain calls to `Base.connection` and
`Base.establish_connection` in active record rake tasks and the
migration code. In a follow up PR I will swap out the `Base` class for a
temporary class which will allow us to stop clobbering `Base` in the
active record rails tasks.

This work is an important step to achieve moving away from Active
Record's dependence on `Base.connection` and
`Base.establish_connection`. The reliance on `Base.connection` is
problematic for sharding support and calling `Base.establish_connection`
in the Rake tasks (without any warning message) indicates it's ok for
applications to do the same (outside these tasks, it's not).

I've vetted the approach of swapping out `Base` for a temporary class in
another branch but decided that it would be easier to demonstrate and
contain the changes if I first contained these calls. The major changes
in this PR are:

* Contain `Base.connection` in `Tasks.migration_connection` and replace
calls to each
* Contain `Base.establish_connection` in `Tasks.establish_connection`
and replace calls to each
* Add a `with_temporary_connection_for_each` method for cases where we
need to loop over each config and set the connection back afterwards
* Add a `with_temporary_connection(db_config)` method for cases where we
have one config but need to establish a new connection and set the old
one back.
* Update every place we were looping through configs to establish a
connection with the new temporary connection methods.

There are a lot of changes here but I've pulled out everything that
didn't need to be in this commit into other PRs.

Once this is merged, I'll create the next PR that replaces `Base` the
new methods in `Tasks` with a temporary connection and then we will
officially be no longer clobbering `Base` in these tasks. This also
reduces complexity because we won't need to ensure we set
`Base.connection` back at the end. Once that is working and all internal
methods are using the new temp class I'll deprecate calls on
`Base.connection` in these methods. Most applications just override the
task but not the actual methods in `Tasks` so my hope is this will be
smooth-ish. However, nothing will stop applications from still using
`Base.connection` for a very long time if they still want to clobber.
2022-12-08 15:38:34 -05:00
Jonathan Hefner
a02c23578e
Merge pull request #46662 from adityapandit17/form-helper-guide-fixes
Fixed form helper documentation [ci-skip]
2022-12-08 13:07:20 -06:00
Aditya Pandit
d83f52cede Fixed form helper documentation [ci-skip] 2022-12-08 23:56:06 +05:30
Eileen M. Uchitelle
a3818028f7
Merge pull request #46671 from Shopify/assert-query-constraints-being-an-empty-array-when-pk-nil
Ensure `query_constraints_list` is empty if `primary_key` is `nil`
2022-12-08 12:38:05 -05:00
Nikita Vasilevsky
448a7b0e04 Ensure query_constraints_list is empty if primary_key is nil 2022-12-08 17:17:24 +00:00
Eileen M. Uchitelle
e98a280b37
Merge pull request #46670 from Shopify/raise-argument-error-if-query-constraints-is-empty
Raise `ArgumentError` on empty `query_constraints` configuration
2022-12-08 12:14:41 -05:00
Nikita Vasilevsky
11e2629fe5 Raise ArgumentError on empty query_constraints configuration 2022-12-08 14:48:54 +00:00
Jean Boussier
51e9fa9bf9
Merge pull request #46614 from Cofense/action_dispatch-response-buffer-write-alias
Add `#<<` alias for `#write` to ActionDispatch::Response::Buffer
2022-12-08 11:18:09 +01:00
Jean Boussier
2c503ae8b2
Merge pull request #46650 from andynu/mail-2-8-0-sendmail-options
Change sendmail default options to match Mail 2.8.x arguments format.
2022-12-08 11:13:21 +01:00
Jonathan Hefner
b02c77f1d5
Merge pull request #46665 from moenodedev/patch-2
Update the Sentry class name
2022-12-07 19:55:39 -06:00
moenodedev
c45d2f7587
Update the Sentry class name 2022-12-07 13:09:11 -08:00
Jean Boussier
ea54939298 Use a single lock for all connections
Followup: https://github.com/rails/rails/pull/46519
Followup: https://github.com/rails/rails/pull/46553
Fix: https://github.com/rails/rails/issues/45994

When using multiple database, `clear_query_caches_for_current_thread` goes
over all connections pool and have to acquire locks one by one to clear each
query cache.

If two threads do this in a different order they might deadlock.

By using a single lock for all connections we avoid this problem entirely
and properly prevent the puma thread from competing with the main thread.

As for previous PRs, it would be cleaner to have this lock around a Rack
middleware, and to release it when calling Capybara primitives like `visit`.
But we need a good chokepoint in Capybara for that, I need to explore that upstream.
2022-12-07 09:38:32 +01:00
Andy
0398459e9a Change sendmail default options to match Mail 2.8.x arguments format.
The Mail gem changed format of the delivery method arguments for
sendmail from a string to an array of strings in this commit
7e1196bd29

As the settings are now a sendmail delivery method produces the
following error:
```
.../mail-2.8.0/lib/mail/network/delivery_methods/sendmail.rb:53:in `initialize': :arguments expected to be an Array of individual string args (ArgumentError)
```

This also updates the mail dependency since the new default won't work
with the older versions.
2022-12-06 20:41:09 -05:00
Eileen M. Uchitelle
90a272a1de
Merge pull request #46658 from rails/fix-internal-metadata-connection
Fix internal_metadata connection
2022-12-06 15:34:32 -05:00
eileencodes
e33b2c65b4
Fix internal_metadata connection
Previously, this code was using `ActiveRecord::Base.connection` for the
internal metadata. However, if a MigrationContext was initialized with a
different connection's internal metadata we should use that. This fixes
the `record_environment` method to use the correct connection for
storing the environment. We noticed this in flaky tests at Shopify
causing internal metadata to get written to the wrong readonly
connection. I have added a test so we don't miss this in the future.
2022-12-06 14:51:18 -05:00