Commit Graph

76846 Commits

Author SHA1 Message Date
fatkodima
6c4f3be929 Unify raise_on_missing_translations for views and controllers 2020-05-20 02:42:59 +03:00
Rafael França
a80115b7c5
Merge pull request #39204 from prathamesh-sonpatki/template-annotation
Add the configuration option for annotating templates with file names to the generated app
2020-05-19 19:11:31 -04:00
Rafael França
1fd894b0d9
Merge pull request #39357 from aried3r/patch-7
Clarify versioning strategy in maintenance policy
2020-05-19 18:45:34 -04:00
Anton Rieder
8ea354304f
Clarify subheadline of maintenance policy
Not all releases are using `X.Y.Z`.
2020-05-20 00:02:04 +02:00
Eugene Kenny
8538dfdc08 Reduce allocations in to_json's include option
Since 7b3919774252f99e55e6b6ec370aafc42adca2b2, `serializable_hash`
allocates fewer objects when options is nil rather than empty.
2020-05-19 22:00:00 +01:00
Ryuta Kamizono
3fe5cf1748 More refactor build_joins 2020-05-20 05:50:08 +09:00
Eileen M. Uchitelle
0043fdcc3a
Merge pull request #39356 from eileencodes/fix-index-exists-check-on-mysql-add-index
Fix index options for if_not_exists/if_exists
2020-05-19 16:49:18 -04:00
eileencodes
5b5da30bc0
Fix index options for if_not_exists/if_exists
The `index_exists?` method wasn't very specific so when we added the
`if_not_exists` to `add_index` and `if_exists` to `remove_index` there
were a few cases where behavior was unexpected.

For `add_index` if you added a named index and then added a second index
with the same columns, but a different name, that index would not get
added because `index_exists` was looking only at column named and not at
the exact index name. We fixed `add_index` by moving the `index_exists`
check below `add_index_options` and pass `name` directly to
`index_exists` if there is a `if_not_exists` option.

For `remove_index` if you added a named index and then tried to remove
it with a nil column and a explicit name the index would not get removed
because `index_exists` saw a nil column. We fixed this by only doing the
column check in `index_exists` if `column` is present.

Co-authored-by: John Crepezzi <john.crepezzi@gmail.com>
2020-05-19 16:19:22 -04:00
Ryuta Kamizono
f799f01964 Consolidate build_left_outer_joins into build_joins 2020-05-20 05:18:12 +09:00
Eugene Kenny
7bf572bd0e
Merge pull request #39312 from eugeneius/parameters_compact
Add compact and compact! to ActionController::Parameters
2020-05-19 21:03:02 +01:00
Eugene Kenny
9b55d5f8d6
Merge pull request #39355 from blaze182/patch-1
Update aws-sdk-s3 dependency
2020-05-19 20:47:14 +01:00
Jonathan Hefner
6e0166037a
Merge pull request #39335 from leetie/master
Update active_record_callbacks.md [ci skip]
2020-05-19 14:38:12 -05:00
Jesse Parsons
60474375ca Update active_record_callbacks.md
Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
2020-05-19 15:33:15 -04:00
Aaron Patterson
715653eb2e
Merge pull request #39347 from p8/did-you-mean-for-parameter-missing
Add DidYouMean for ParameterMissing
2020-05-19 12:14:11 -07:00
eileencodes
58cf1a5fb5
Stop calling methods directly on Journey
Journey is a private API that we want to refactor. We need to stop
calling methods directly on it so we're free to change the
implmentation.
2020-05-19 13:31:37 -04:00
Aaron Patterson
e3c7ba4612
Merge pull request #39338 from p8/did-you-mean-for-has-many-through
Add DidYouMean for HasManyThroughAssociationNotFoundError
2020-05-19 08:37:01 -07:00
Paul Blaze
84057dab16
Update aws-sdk-s3 dependency
whitelist_headers support added in 1.48.0:
https://github.com/aws/aws-sdk-ruby/blob/master/gems/aws-sdk-s3/CHANGELOG.md#1480-2019-08-30
2020-05-19 23:09:39 +08:00
Petrik
5411565d44 Add DidYouMean for ParameterMissing
If a parameter isn't found we can suggest similar params:

```
class BooksController < ActionController::Base
  def create
    params.require(:book).require(:name)
    head :ok
  end
end

post :create, params: { magazine: { name: "Mjallo!" } }

param is missing or the value is empty: book
Did you mean?  controller
               action
               magazine

post :create, params: { book: { title: "Mjallo!" } }

param is missing or the value is empty: name
Did you mean?  title

```
2020-05-19 10:50:24 +02:00
Petrik
9082364a25 Add DidYouMean for HasManyThroughAssociationNotFoundError
If a has_many :through association isn't found we can suggest similar associations:

```
class Author
  has_many :categorizations, -> { }
  has_many :categories, through: :categorizations
  has_many :categorized_posts, through: :categorizations, source: :post
  has_many :category_post_comments, through: :categories, source: :post_comments

  has_many :nothings, through: :kateggorisatons, class_name: "Category"
end

Author.first.nothings

Could not find the association :kateggorisatons in model Author
Did you mean?  categorizations
               categories
               categorized_posts
               category_post_comments
```
2020-05-19 08:27:08 +02:00
Prathamesh Sonpatki
a673ce69e7
Rename annotate_template_file_names to annotate_rendered_view_with_filenames
- Add the configuration option for annotating templates with file names to the generated app.
- Add `annotate_rendered_view_with_filenames` option to configuring guide.
2020-05-19 09:28:14 +05:30
Vitalii Khustochka
1ab0e6b6d8
Update fixture_file_upload documentation to reflect recent changes. (#39340)
* Update `fixture_file_upload` documentation to reflect recent changes. [ci skip]

* Friendlier deprecation message for `fixture_file_upload`.

Suggested change now can be copied and pasted into the code without modification.
2020-05-18 23:14:33 +02:00
Ryuta Kamizono
4774fa0d26 Test multiple values with blank value 2020-05-19 04:57:00 +09:00
Jonathan Hefner
c08ee7f142
Merge pull request #39336 from Jberczel/master
Fix references in the form builders guide [ci skip]
2020-05-18 14:27:51 -05:00
Jamie
7817996fc4
Fix references in the form builders guide [ci skip]
I caught two references that seemed inconsistent:

1. In section 2.2 Binding a Form to an Object, the code snippet variable was called `form`, but in the bullet points below, it was referenced as `f`.
2. In section 6 Uploading Files, the references to the params hash returned by two different forms was incorrect.
2020-05-18 14:55:23 -04:00
Ryuta Kamizono
a31759ca20
Merge pull request #39333 from kamipo/unify_query_values_normalization
Unify the query values normalization for multiple values
2020-05-19 03:21:46 +09:00
Ryuta Kamizono
1494fadd0d Fix test_two_classes_autoloading failure
That test requires Marshal is prepended by `MarshalWithAutoloading`.
2020-05-19 02:57:46 +09:00
Aaron Patterson
d5e099490e
Merge pull request #39319 from p8/did-you-mean-for-action-not-found
Use DidYouMean for ActionNotFound
2020-05-18 10:30:03 -07:00
Ryuta Kamizono
6038755377 Unify the query values normalization for multiple values
Currently the query values normalization for multiple values is missing
some parts.

Some values are flatten, but others are not flatten.
Some values are compact, but others are not compact.
some values are compact_blank, but others are not compact_blank.

Originally all multiple values should be flatten and compact_blank
before `build_arel`, if it is not ensured which multiple values are
normalized or not, we need to normalize it again carefully and
conservatively in `build_arel`.

To unify the query values normalization for multiple values, ensure the
normalization in `check_if_method_has_arguments!` since all multiple
values should be checked by the method.
2020-05-19 01:07:51 +09:00
Ryuta Kamizono
393df7425f Fix syntax error 2020-05-19 01:04:22 +09:00
Aaron Patterson
b472feddbc
Merge branch 'master-sec'
* master-sec:
  Check that request is same-origin prior to including CSRF token in XHRs
  HMAC raw CSRF token before masking it, so it cannot be used to reconstruct a per-form token
  activesupport: Avoid Marshal.load on raw cache value in RedisCacheStore
  activesupport: Avoid Marshal.load on raw cache value in MemCacheStore
  Return self when calling #each, #each_pair, and #each_value instead of the raw @parameters hash
  Include Content-Length in signature for ActiveStorage direct upload
2020-05-18 08:48:41 -07:00
Petrik
3551a95e53 Use DidYouMean for ActionNotFound
If an action isn't found on a controller we can suggest similar actions:

```
The action 'indx' could not be found for SimpleController
Did you mean?  index
```
2020-05-18 15:41:26 +02:00
Ryuta Kamizono
cdbce035a5
Merge pull request #39330 from kamipo/fix_merge_not_in
Fix merging NOT IN clause to behave the same as before
2020-05-18 21:48:36 +09:00
Ryuta Kamizono
13a3f62ae8 Fix merging NOT IN clause to behave the same as before
`HomogeneousIn` has changed merging behavior for NOT IN clause from
before. This changes `equality?` to return true only if `type == :in` to
restore the original behavior.
2020-05-18 15:56:44 +09:00
Ryuta Kamizono
fa63e5f03e
Merge pull request #39219 from kamipo/bind_param
Should not substitute binds when `prepared_statements: true`
2020-05-18 15:20:00 +09:00
Ryuta Kamizono
972f22e42a
Merge pull request #39250 from kamipo/support_rewhere_for_merge
Support merging option `:rewhere` to allow mergee side condition to be replaced exactly
2020-05-18 14:56:18 +09:00
Ryuta Kamizono
f6fb3271d4 Support merging option :rewhere to allow mergee side condition to be replaced exactly
Related #39236.

`relation.merge` method sometimes replaces mergee side condition, but
sometimes maintain both conditions unless `relation.rewhere` is used.

It is very hard to predict merging result whether mergee side condition
will be replaced or not.

One existing way is to use `relation.rewhere` for merger side relation,
but it is also hard to predict a relation will be used for `merge` in
advance, except one-time relation for `merge`.

To address that issue, I propose to support merging option `:rewhere`,
to allow mergee side condition to be replaced exactly.

That option will allow non-`rewhere` relation behaves as `rewhere`d
relation.

```ruby
david_and_mary = Author.where(id: david.id..mary.id)

# both conflict conditions exists
david_and_mary.merge(Author.where(id: bob)) # => []

# mergee side condition is replaced by rewhere
david_and_mary.merge(Author.rewhere(id: bob)) # => [bob]

# mergee side condition is replaced by rewhere option
david_and_mary.merge(Author.where(id: bob), rewhere: true) # => [bob]
```
2020-05-18 14:36:42 +09:00
Ryuta Kamizono
a095916df1
Merge pull request #39321 from kamipo/fix_update_with_dirty_locking_column
Fix update with dirty locking column to not match latest object accidentally
2020-05-18 11:46:04 +09:00
Ryuta Kamizono
12250a6ce9
Merge pull request #39323 from kamipo/fix_rename_column_for_postgresql
Fix rename column in bulk alter table for PostgreSQL
2020-05-18 11:43:20 +09:00
Ryuta Kamizono
6bd2bb7526 Fix rename column in bulk alter table for PostgreSQL
PostgreSQL doesn't support rename column operation in bulk alter table.

Fixes #39322.
2020-05-18 11:14:29 +09:00
Ryuta Kamizono
fba016c7a3 Fix update with dirty locking column to not match latest object accidentally
Related #32163.

We should not identify an object by dirty value. If do so, accidentally
matches latest object even though it is a stale object.
2020-05-18 09:46:09 +09:00
John Hawthorn
2f62effc34
Merge pull request #39307 from jhawthorn/skip_interpolated_strings_in_digestor
Skip interpolated strings in AV::Digestor
2020-05-17 16:37:29 -07:00
Ryuta Kamizono
c360644ed9 Do not need explicit handler for InfixOperation's subclasses
Unless explicitly intend to behave it differently from the superclass.
2020-05-18 08:18:55 +09:00
Ryuta Kamizono
74e826a9e9 Use symbol consistently for operator in InfixOperation 2020-05-18 08:02:00 +09:00
Aaron Patterson
b027288823
Merge pull request #39318 from p8/did-you-mean-for-associations
Use DidYouMean for AssociationNotFoundError
2020-05-17 15:24:13 -07:00
Ryuta Kamizono
a2a861d357 ✂️ trailing spaces [ci skip] 2020-05-18 07:16:18 +09:00
John Hawthorn
d6a01650aa Skip interpolated strings in AV::Digestor 2020-05-17 15:06:17 -07:00
Eugene Kenny
a061d9012f
Merge pull request #39285 from fatkodima/refactor-as_json
Avoid allocating extra hash and arrays when as_json is called without options
2020-05-17 22:45:12 +01:00
fatkodima
7b39197742 Avoid allocating extra hash and arrays when as_json is called without options
Co-authored-by: Eugene Kenny <elkenny@gmail.com>
2020-05-17 22:54:55 +03:00
Petrik
3bc7756036 Use DidYouMean for AssociationNotFoundError
If an association isn't found we can suggest matching associations:

```
Post.all.merge!(includes: :monkeys).find(6)

Association named 'monkeys' was not found on Post; perhaps you misspelled it?
Did you mean?  funky_tags
               comments
               images
               skimmers
```
2020-05-17 21:32:19 +02:00
Ryuta Kamizono
b0d0feabb9 Remove redundant looking type up from explicit klass.attribute_types
In aggregation value's type cast, `klass.attribute_types.fetch(...)`
will find no type almost all cases, since any type is already returned
by `column.type_caster` in that case.
And also, the root of join dependency tree is also the model's `klass`,
so the explicit `klass.attribute_types` is redundant originally.
2020-05-18 03:25:05 +09:00