Commit Graph

86975 Commits

Author SHA1 Message Date
Americo Savinon
c0a6963b63 [skip-ci] adding missing config generator line to prevent creating stylesheets inside generators.rb (section: Customizing Your Workflow) 2023-03-20 14:26:28 +01:00
Vipul A M
05c3f84a51
Merge pull request #47709 from sampatbadhe/patch-4 2023-03-18 19:30:34 +05:30
sampatbadhe
d9d8d8a4d2 Correct typos in activerecord changelog and querylogs docs [ci-skip] 2023-03-18 19:07:41 +05:30
Rafael Mendonça França
e23e1718ea
Merge pull request #47690 from andrewn617/add-on-load-callback-for-active-record-fixtures
Run a load hook when TestFixtures is included
2023-03-17 14:10:52 -04:00
Andrew Novoselac
49283adc16 Run a load hook when TestFixtures is included 2023-03-17 13:36:48 -04:00
Jonathan Hefner
29441c0e2f
Merge pull request #47701 from skipkayhil/fix-ujs-tests-not-linted
Fix rails-ujs tests not being linted
2023-03-17 11:12:44 -05:00
Shouichi Kamiya
0ad120b72e Add nodoc to ActiveRecord::FixtureSet::ClassCache [skip ci]
I believe this is an implementation detail.
2023-03-17 15:21:05 +09:00
Hartley McGuire
03366a6d5d
Fix rails-ujs tests not being linted
Before rails-ujs was [updated][1] from coffeescript to es6, the lint
task ran eslint on both the coffee files and the ujs test files. When it
was updated to lint the new es6 files, the test files were erroneously
left out.

This commit fixes the task to lint the rails-ujs test files and fixes
the lint errors that have been introduced since.

[1]: 7d116c93cf6cf2470600860c4c17417df7768c34
2023-03-17 00:56:59 -04:00
Eileen M. Uchitelle
f91bd408f3
Merge pull request #47697 from JuanVqz/railties/match-classes-names-with-the-filename
Rename classes to the filename
2023-03-16 17:41:49 -04:00
Juan Vasquez
75d6eeb7b2 Rename classes to the filename
Given a [small question](https://github.com/rails/rails/pull/47623/files#r1139287593)
and to remove inconsistent filename and classes names in some command
tests we are opening this PR to match them and remove the inconsistent
2023-03-16 14:44:27 -06:00
Eileen M. Uchitelle
3827576325
Merge pull request #47692 from Shopify/fix-querying-by-whole-record-for-query-constraints-models
Allow querying by whole record for composite query constraints associations
2023-03-16 14:39:01 -04:00
Nikita Vasilevsky
95a3e6cd0a Allow querying by whole record for composite query constraints associations
Given an association defined with composite query constraints like:
```ruby
BlogPost.has_many :comments, query_constraints: [:blog_id, :blog_post_id]
```

it is possible to query blog posts by whole `comments` objects like:

```ruby
comments = Comment.first(2)
BlogPost.where(comments: comments).to_a
```
2023-03-16 17:02:50 +00:00
Jean Boussier
210932662b Also undefine with on Symbol 2023-03-16 11:04:19 +00:00
Jean Boussier
a4d7ed1018
Merge pull request #47688 from Shopify/object-with-immediates
Undefine `with` on NilClass and other common immediate types
2023-03-16 10:43:45 +00:00
Jean Boussier
dc6bfecdef Undefine with on NilClass and other common immediate types
with isn't usable on immediates, so we might as well undefine the
method in common immediate classes to avoid potential confusion.
2023-03-16 10:29:54 +00:00
Jonathan Hefner
13ea2d76d0
Merge pull request #47682 from tiramizoo/non-default-env-example
Add example of simple environment config extending [ci-skip]

Co-authored-by: Hartley McGuire <skipkayhil@gmail.com>
2023-03-15 15:42:58 -05:00
Wojciech Wnętrzak
e0e7030f99
Add example of simple environment config extending
Follow up to https://github.com/rails/rails/issues/47570

[ci skip]

Update guides/source/configuring.md

Co-authored-by: Hartley McGuire <skipkayhil@gmail.com>

Update guides/source/configuring.md

Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
2023-03-15 21:23:56 +01:00
Jonathan Hefner
13dc6e76fb
Merge pull request #47685 from jonathanhefner/rely-autoload-active_model-forbidden_attributes_protection
Rely on `AM::ForbiddenAttributesProtection` autoload
2023-03-15 14:11:46 -05:00
Jonathan Hefner
9f399a6b6b Rely on AM::ForbiddenAttributesProtection autoload
`ActiveModel::ForbiddenAttributesProtection` is autoloaded, so this
`require` is not necessary.
2023-03-15 13:23:00 -05:00
Jonathan Hefner
8986050c41
Merge pull request #47683 from yskkin/patch-3
Remove redundant require: follow #10776
2023-03-15 13:16:20 -05:00
Jonathan Hefner
a51364dcf1
Merge pull request #47619 from p8/railties/thor-restart-task
Use Thor for built-in restart task
2023-03-15 11:38:07 -05:00
Matthew Draper
0dc919b544
Merge pull request #47684 from rails/revert-47493-quote_binary_strings
Revert "Quote binary strings in Arel"
2023-03-16 01:40:13 +10:30
Eileen M. Uchitelle
3b7e4134e5
Merge pull request #47664 from Shopify/support-composite-identifier-in-find
Extend `ActiveRecord::FinderMethods#find` with support for composite pk values
2023-03-15 10:57:34 -04:00
Nikita Vasilevsky
7375ff2494 Introduce ActiveRecord::PrimaryKey#composite_primary_key? abstraction
Initial implementation falls back to `primary_key.is_a?(Array)` so
it can be immediately used in place of direct `is_a?` checks.
Though implementation may be changed to rely on a pre-initialized
`@composite_primary_key` ivar in the future.
2023-03-15 13:45:23 +00:00
Nikita Vasilevsky
b05321d31a Extend ActiveRecord::FinderMethods#find with support for composite pk values
`ActiveRecord::FinderMethods#find` now supports passing sets of
composite primary key values like:

```ruby
Cpk::Book.find([1, 1])
Cpk::Book.find([[1, 1]])
Cpk::Book.find([1, 1], [1, 2])
Cpk::Book.find([[1, 1], [1, 2]])
```

and treats values as values of the composite primary key columns but
only for models with the `primary_key` being an `Array`.
2023-03-15 13:44:54 +00:00
Eileen M. Uchitelle
9527e5e307
Merge pull request #47668 from Shopify/pm/destroy-async-composite-keys
Destroying associations asynchronously respect query constraints
2023-03-15 09:18:42 -04:00
Rafael Mendonça França
74554cde8b
Merge PR #47675 2023-03-15 13:05:44 +00:00
Petrik
51c965c431 Use Thor for built-in restart task
Currently we use both Thor and Rake for `bin/rails` commands.
We eventually want to get all the built-ins task promoted to Thor Commands.
This migrates the `restart` task to Thor.

With this change it also possible to restart outside the application
directory:

```bash
blog/bin/rails restart
```

Co-authored-by: Hartley McGuire <skipkayhil@gmail.com>
Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
2023-03-15 13:09:48 +01:00
Matthew Draper
bb7f3be138
Revert "Quote binary strings in Arel" 2023-03-15 19:50:50 +10:30
Yoshiyuki Kinjo
db944ce3b2
Remove redundant require: follow #10776
active_model/forbidden_attributes_protection is not used since #10776
2023-03-15 18:16:51 +09:00
Jean Boussier
335733b858
Merge pull request #47649 from fatkodima/retry-flaky-secure_password-test 2023-03-15 08:56:39 +00:00
Yasuo Honda
7d88419227
Merge pull request #47681 from skipkayhil/fix-changelog-rubygems-version
Fix rubygems version mentioned in CHANGELOG
2023-03-15 13:36:28 +09:00
Hartley McGuire
b40c5f2512
Fix rubygems version mentioned in CHANGELOG
The version check [added][1] is for 3.3.13, but the CHANGELOG specifies
3.3.16

[1]: 7da3353b60749426aac27c6b43d589448f3a3cd0
2023-03-14 23:56:23 -04:00
zzak
dadf46de36
Add rubocop-md for linting guides snippets 2023-03-15 10:48:19 +09:00
Yasuo Honda
126d2169d0
Merge pull request #47655 from alpaca-tc/deferrable_exclusion_constraint
Adds support for deferrable exclude constraints in PostgreSQL.
2023-03-15 08:27:01 +09:00
Paarth Madan
a270108bf6 Destroy associations async respect query constraints
The codepaths related to destroying associations asynchronously now
consider when query constraints are present. In most cases, this means
interpreting the primary key as an array of columns, and identifying
associated records by a tuple of these columns, where previously this
would've been a single ID. In each of the callsites, we use branching.
This is done to maintain backwards compatibility and ensure the
signature of the destroy job remains stable: it has consumers outside of
Rails.
2023-03-14 19:09:09 -04:00
Andrew Novoselac
6902cbce1b Introducs TestFixtures#fixture_paths.
Multiple fixture paths can now be specified using the `#fixture_paths` accessor.
2023-03-14 19:02:56 -04:00
Jonathan Hefner
96fa75e321
Merge pull request #47663 from p8/railties/remove-unused-command-requires-in-tests
Remove unused requires in command test cases
2023-03-14 16:40:39 -05:00
Jonathan Hefner
bed48e6d8f
Merge pull request #47676 from jonathanhefner/rake_command-fix-task-arguments
Fix Rake-style task arguments for `bin/rails`
2023-03-14 16:32:33 -05:00
Jonathan Hefner
72b7a8924a Fix Rake-style task arguments for bin/rails
Follow-up to #47208.

When using Rake-style CLI arguments, `Rake::Application#top_level_tasks`
will return the full task invocation rather than the parsed task name.
For example, when running `rake foo[bar] baz[qux]`, `top_level_tasks`
will return `["foo[bar]", "baz[qux]"]` rather than `["foo", "baz"]`.
Therefore, we must extract the task name before checking existence.
2023-03-14 16:06:28 -05:00
Eileen M. Uchitelle
fdceee8d78
Merge pull request #47674 from Shopify/nodoc-valid-options
Add `nodoc` to `valid_*_options` methods
2023-03-14 15:38:42 -04:00
Hormoz Kheradmand
34d8a65969
add nodoc to valid_*_options methods 2023-03-14 12:32:58 -07:00
Rafael Mendonça França
ef4841eac8
Update link to the security announcements list 2023-03-14 17:46:06 +00:00
Eileen M. Uchitelle
c5530fd989
Merge pull request #47673 from eileencodes/pass-self-directly-for-establish-connection
Pass `self` directly to `connection_class`
2023-03-14 11:46:05 -04:00
eileencodes
0603d512dc
Pass self directly to connection_class
Returning `self` and `db_config` from `resolve_config_for_connection` is
hold over from legacy behavior when we returned `self.name` or
`Base.name` rather than just `self`. We can simplify this by passing
`self` directly` to the handlers `establish_connection`.
2023-03-14 11:26:11 -04:00
Greg Molnar
2602ca89ae move directory existence check for code statistics task inside of the task
otherwise, if a gem appends to the constant, we can end up with an
error.
2023-03-14 13:57:48 -01:00
alpaca-tc
cbc7b59749 Adds support for deferrable exclude constraints in PostgreSQL.
By default, exclude constraints in PostgreSQL are checked after each statement.
This works for most use cases, but becomes a major limitation when replacing
records with overlapping ranges by using multiple statements.

```ruby
exclusion_constraint :users, "daterange(valid_from, valid_to) WITH &&", deferrable: :immediate
```

Passing `deferrable: :immediate` checks constraint after each statement,
but allows manually deferring the check using `SET CONSTRAINTS ALL DEFERRED`
within a transaction. This will cause the excludes to be checked after the transaction.

It's also possible to change the default behavior from an immediate check
(after the statement), to a deferred check (after the transaction):

```ruby
exclusion_constraint :users, "daterange(valid_from, valid_to) WITH &&", deferrable: :deferred
```

*Hiroyuki Ishii*
2023-03-14 23:29:35 +09:00
Eileen M. Uchitelle
95fe1f3a99
Merge pull request #45041 from jasonkarns/delegated-type-column
Delegated Type supports customizeable foreign_type column
2023-03-14 09:58:32 -04:00
Jason Karns
1f61fd65ae
Delegated Type supports customizeable foreign_type column 2023-03-14 09:19:30 -04:00
Petrik
4f559f7265 Remove unused requires in command test cases
If the command class isn't invoked directly we don't need to require the
class.
2023-03-14 08:53:28 +01:00