Commit Graph

83583 Commits

Author SHA1 Message Date
Jean Boussier 79b087ebda
Merge pull request #45036 from fatkodima/insert_all-attribute-aliases
Allow using aliased attributes with `insert_all`/`upsert_all`
2022-05-11 11:01:27 -04:00
fatkodima fd2afb331e Allow using aliased attributes with `insert_all`/`upsert_all` 2022-05-11 16:46:26 +03:00
Petrik de Heus 5942211feb
Merge pull request #45065 from p8/guides/rename-contributions-to-contributing
Rename "Contributions" Guides section to "Contributing"
2022-05-11 14:22:29 +02:00
Eileen M. Uchitelle 7d73553557
Merge pull request #45067 from fatkodima/mysql-view-default
Fix getting column default from VIEW in mysql
2022-05-11 07:41:37 -04:00
fatkodima 6b67a3c882 Fix getting column default from VIEW in mysql 2022-05-11 13:54:50 +03:00
Petrik 51dd7f01c4 Rename Guides "Contributions" section to "Contributing" [ci-skip]
The Contributions section in the guides doesn't document "contributions
to Rails" but "how to Contribute to Rails".
2022-05-11 11:28:26 +02:00
Ryuta Kamizono 3b4e476221
Merge pull request #45052 from yahonda/strscan_302
Bump strscan to 3.0.2 to address bug_report_templates/action_controller_gem.rb
2022-05-11 07:11:23 +09:00
Gannon McGibbon 4b3af4795b
Merge pull request #45058 from p8/docs/css-version-badge
Use the CSS badge for the API docs as well
2022-05-10 16:00:11 -04:00
Petrik 55073ac10f Use the CSS badge for the API docs as well
Sdoc 2.4.0 supports a CSS badge that can be set by passing the version
as the HORO_BADGE_VERSION env variable.

The old badge image can be removed, as it no longer needs to be copied
by the docs server: https://github.com/rails/rails-docs-server/pull/28
2022-05-10 21:05:59 +02:00
Eileen M. Uchitelle 88c0e2c950
Merge pull request #44370 from mohits/patch-1
Provide change summary before details for all gems
2022-05-10 11:34:03 -04:00
Jean Boussier 4ea281c39c
Merge pull request #45047 from fatkodima/fix-cache-expires_at
Set ttl for redis and memcache cache stores when using `expires_at`
2022-05-10 14:22:34 +02:00
fatkodima ded8301375 Set ttl for redis and memcache cache stores when using `expires_at` 2022-05-10 14:37:11 +03:00
Yasuo Honda 76ac6e9a98 Bump strscan to 3.0.2 to address bug_report_templates/action_controller_gem.rb
This commit addresses the following error.

```
% ruby -v
ruby 2.7.6p219 (2022-04-12 revision c9c2245c0a) [arm64-darwin21]
% cd guides/bug_report_templates
% ruby action_controller_gem.rb
Fetching gem metadata from https://rubygems.org/...........
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies...
... snip ...
Fetching strscan 3.0.2
Installing strscan 3.0.2 with native extensions
Traceback (most recent call last):
	9: from action_controller_gem.rb:5:in `<main>'
	8: from /Users/yahonda/.rbenv/versions/2.7.6/lib/ruby/2.7.0/bundler/inline.rb:54:in `gemfile'
	7: from /Users/yahonda/.rbenv/versions/2.7.6/lib/ruby/2.7.0/bundler/settings.rb:124:in `temporary'
	6: from /Users/yahonda/.rbenv/versions/2.7.6/lib/ruby/2.7.0/bundler/inline.rb:70:in `block in gemfile'
	5: from /Users/yahonda/.rbenv/versions/2.7.6/lib/ruby/2.7.0/bundler/runtime.rb:26:in `setup'
	4: from /Users/yahonda/.rbenv/versions/2.7.6/lib/ruby/2.7.0/bundler/runtime.rb:26:in `map'
	3: from /Users/yahonda/.rbenv/versions/2.7.6/lib/ruby/2.7.0/bundler/spec_set.rb:147:in `each'
	2: from /Users/yahonda/.rbenv/versions/2.7.6/lib/ruby/2.7.0/bundler/spec_set.rb:147:in `each'
	1: from /Users/yahonda/.rbenv/versions/2.7.6/lib/ruby/2.7.0/bundler/runtime.rb:31:in `block in setup'
/Users/yahonda/.rbenv/versions/2.7.6/lib/ruby/2.7.0/bundler/runtime.rb:312:in `check_for_activated_spec!': You have already activated strscan 3.0.1, but your Gemfile requires strscan 3.0.2. Prepending `bundle exec` to your command may solve this. (Gem::LoadError)
%
```

Background:
- It has been failing since this build
https://buildkite.com/rails/rails/builds/86305#9be4d24a-2944-4660-b5f0-03aac7992131

- strscan  3.0.2 has been released on May 9, 2022
https://rubygems.org/gems/strscan/versions/3.0.2
2022-05-10 08:47:26 +09:00
Nathaniel Watts da05fa3381
Fix for multiple default_scope all_queries options
In our use case - we have a base model that has a default scope that we
want enabled for all queries, ex:

```ruby
class Developer < ApplicationRecord
  default_scope -> { where(firm_id: Current.firm_id) }, all_queries:
  true
end
```

We're also leveraging a module that will add a default scope to only
find soft-deleted records.

```ruby
module SoftDeletable
  extend ActiveSupport::Concern

  included do
    default_scope { where(deleted_at: nil) }
  end
```

Through this, we've found that when using default scopes in combination,
*specifically in the use case where the _non_ all queries scope is
declared first*, that we would get an error when calling `.update`:

```ruby
class Developer < ApplicationRecord
  include SoftDeletable

  default_scope -> { where(firm_id: Current.firm_id) }, all_queries:
  true
```

```ruby
Current.firm_id = 5

developer = Developer.new(name: "Steve")

developer.update(name: "Stephen")

NoMethodError: undefined method `where' for nil:NilClass
```

In digging into the code, this was due to there not being an `else` case
for the `inject` used to combine `default_scopes` together (`inject`
  uses the return value of the block as the memoizer).

Without the `else` case, if the block returned `nil`, `nil` was passed
to the evaluation of the next `default_scope`.

This commit adds the `else`, and also makes a minor adjustment in
variable naming (`default_scope` to `combined_scope`) in an effort to
add a little more readability, as we're iterating over an array of
default scopes, but what we're building is _the_ default scope to be
used in the query, etc.

Co-authored-by: Will Cosgrove <will@cosgrove.email>
2022-05-09 16:34:18 -04:00
Eileen M. Uchitelle d94b65aad6
Merge pull request #45033 from basecamp/encrypt-default-attributes
Support encrypted attributes on columns with default values
2022-05-09 08:13:52 -04:00
Petrik de Heus 068c783adb
Merge pull request #44965 from equivalent/patch-2
AzureStorage needs version >= 2 of azure-storage-blob
2022-05-09 13:13:05 +02:00
Petrik de Heus fa6483ca98
Merge pull request #45043 from pocke/Add_anchor_to_a_link_in__load_defaults__s_api_guide__ci_skip_
Add anchor to a link in `load_defaults`'s api guide [ci-skip]
2022-05-09 12:48:12 +02:00
Petrik de Heus a6f085b73a
Merge pull request #45044 from mikdiet/patch-1
Fix a typo in Active Record Encryption guide
2022-05-09 12:44:45 +02:00
Mikhail Dieterle a80a225085
Fix a typo in Active Record Encryption guide 2022-05-09 13:14:02 +03:00
Masataka Pocke Kuwabara 0768e83492 Add anchor to a link in `load_defaults`'s api guide [ci-skip] 2022-05-09 17:29:28 +09:00
Jean Boussier 38d5846e06
Merge pull request #44910 from jonathanhefner/credentials-avoid-escaping-paths
Avoid escaping paths when editing credentials
2022-05-09 10:11:39 +02:00
Jean Boussier f19e896d0d
Merge pull request #44961 from franzliedke/patch-1
Complete check for custom CSRF storage strategies
2022-05-09 10:08:42 +02:00
Jean Boussier 4fed54f0a6
Merge pull request #44979 from acronin-stash/fix-module-middleware-name
Correctly get name of middleware when a it is Module
2022-05-09 10:07:38 +02:00
Jean Boussier ac8fd700bb
Merge pull request #44985 from jonathanhefner/client9-misspell-immutable-url
Use immutable URL for arbitrary code
2022-05-09 10:01:41 +02:00
Jean Boussier dd0b302378
Merge pull request #45029 from jonathanhefner/fix-extract_dimensions-regexp
Escape literal dot in regular expression
2022-05-09 09:55:00 +02:00
Hartley McGuire 05a6176474
Fix typo in development dependencies (#45042) 2022-05-08 17:49:06 -04:00
Jonathan Hefner 8dce413b44
Merge pull request #44947 from jasonkarns/patch-3
Fix link to Thor's docs [ci-skip]
2022-05-08 10:31:19 -05:00
Jason Karns 1d5bddc082 Fix link to Thor's docs
Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
2022-05-08 10:24:49 -05:00
Jorge Manrubia 238432d1cb
Support encrypted attributes on columns with default values
Before, it was failing to read these columns because their contents
were not encrypted, unless you enabled `config.active_record.encryption.support_unencrypted_data`.

Now, it will detect the change at creation time for these records and
effectively encrypt those values, preventing the problem.

Fixes #44314 #43664
Closes #44993

Co-authored-by: Dima Fatko <fatkodima123@gmail.com>
2022-05-07 22:16:34 +02:00
Gannon McGibbon 377ae3cee6
Merge pull request #44866 from stefkin/acp-consistent-has-value
Make behaviour of has_value?/value? more consistent
2022-05-06 10:14:35 -04:00
Seva Stefkin 743ab43686
Make behaviour of has_value?/value? more consistent 2022-05-06 15:52:22 +02:00
Eileen M. Uchitelle c7b7fe0de0
Merge pull request #45032 from tmyksj/reformat-code-in-placeholder-conditions
docs: Reformat code in Placeholder Conditions [ci-skip]
2022-05-06 09:14:53 -04:00
tmyksj 57dcca2ab8 Reformat code in Placeholder Conditions
This commit inserts spaces inside curly brackets in Placeholder
Conditions to follow the coding conventions.
2022-05-06 20:13:46 +09:00
Jonathan Hefner fe24f5880d Escape literal dot in regular expression
Follow-up to #44669.

This ensures that e.g. sizes with commas are not erroneously matched.
2022-05-05 14:08:43 -05:00
Eileen M. Uchitelle 480edd4906
Merge pull request #45027 from rails/fix-tag-helper-regression
Fix tag helper regression
2022-05-05 14:46:19 -04:00
Eileen M. Uchitelle cd2949d2d9
Merge pull request #45016 from adrianna-chang-shopify/ac-fix-strict-loading-polymorphic-associations
Raise StrictLoadingViolationError with polymorphic relation violations
2022-05-05 11:32:16 -04:00
Adrianna Chang 71828a4bfb Raise StrictLoadingViolationError with polymorphic relation violations
Performing strict_loading! on a model with a polymorphic association
currently raises an ArgumentError because it attempts to look up the
klass on the polymorphic association, which is not possible. The error
message for StrictLoadingViolationError on models with polymorphic
relationships should omit the klass for the association.
2022-05-05 11:02:53 -04:00
eileencodes 944bcb54f6
Fix tag helper regression
Vue.js, alpinejs, and potentially other JS libraries support tags
starting with `@` symbols. This was broken by the recent security release in
649516ce0f

I've only added `@` to the list even though there are potentially other
safe characters. We can add more if necessary (and if safe).

Fixes:
* #45014
* #44972
2022-05-05 10:42:41 -04:00
Jean Boussier 761e3aa344
Merge pull request #44998 from Shopify/error-reporting-source
Error reporting API: Add a context source attribute
2022-05-05 10:58:21 +02:00
Jean Boussier c9a2bc284c Error reporting API: Add a source attribute
Ref: https://github.com/rails/rails/pull/43625#issuecomment-1109595539

Some users may not be interested by some internal errors.
By providing a `source` attribute we allow to easilly filter
these errors out.
2022-05-05 10:57:21 +02:00
Eileen M. Uchitelle df1e1bc35c
Merge pull request #45018 from lucthev/lt/strict-false
Fix disabling strict_loading when enabled by default
2022-05-04 14:09:41 -04:00
Luc Thevenard 303b5145f5 Fix disabling strict_loading when enabled by default 2022-05-04 10:17:59 -04:00
Jean Boussier d7ac149f5f Use mysql2 0.5.4 2022-05-04 13:21:24 +02:00
Jonathan Hefner 8bc187dbcc
Merge pull request #45013 from JohnAnon9771/fix/doc-active-record-querying
Doc: fix of name attribute [ci-skip]
2022-05-03 15:52:09 -05:00
JohnAnon9771o 5d86ff86c8 fix: name of attribute of name to first_name in dynamic finders doc 2022-05-03 17:23:26 -03:00
Jean Boussier 1b884cfe8a
Merge pull request #44983 from shiro16/dalli-store-optimised-cache-read_multi
Fixed: MemCacheStore#read_multi_entries NoMethodError: undefined method `expired?` for nil:NilClass
2022-05-03 19:06:57 +02:00
Jean Boussier c30ef14927
Merge pull request #44937 from fatkodima/missing-exceptions-require
Add missing require of `action_controller/metal/exceptions` to `action_controller`
2022-05-03 19:03:53 +02:00
Jonathan Hefner e4ec2cbb49
Merge pull request #44777 from jean-francois-labbe/main
Document action mailer rescue_from [ci-skip]
2022-05-03 10:47:38 -05:00
Eileen M. Uchitelle 3c48b4030a
Merge pull request #45012 from fatkodima/fix-sql-comments-regex
Simplify regex detecting comments in sql query
2022-05-03 08:49:05 -04:00
fatkodima f63a347d13 Simplify regex detecting comments in sql query 2022-05-03 12:59:26 +03:00