Commit Graph

70582 Commits

Author SHA1 Message Date
Sean Griffin b63701e272 `update_columns` raises if the column is unknown
Previosly, `update_columns` would just take whatever keys you gave it
and tried to run the update query. Most likely this would result in an
error from the database. However, if the column actually did exist, but
was in `ignored_columns`, this would result in the method returning
successfully when it should have raised, and an attribute that should
not exist written to `@attributes`.
2018-10-30 12:52:23 -06:00
Gannon McGibbon 9a18a10e1c
Merge pull request #34314 from bf4/patch-2
ActionController::API *does* support cookies, sessions
2018-10-30 14:14:00 -04:00
Ryuta Kamizono 405aef3ded
Merge pull request #34349 from yahonda/restore_encoding_utf8mb4
Restore `encoding: utf8mb4` in database.yml
2018-10-30 22:12:45 +09:00
Ryuta Kamizono 9ae3ddbb21
Merge pull request #19388 from yakara-ltd/fix-habtm-fixture-order
Avoid violating key constraints in fixture HABTM associations
2018-10-30 22:04:19 +09:00
Eileen M. Uchitelle 6889e720cc Merge pull request #34196 from gmcgibbon/connection_switch_string_name
Add support for hash and url configs to be used in connected_to
2018-10-30 08:56:34 -04:00
Yasuo Honda 639f8fd9e5 Restore `encoding: utf8mb4` in database.yml
rails/rails#33853 and rails/rails#33929 removed `encoding: utf8mb4` from database.yml
since at that time MySQL 5.1 is supported with the master branch.

Since MySQL 5.1 has been dropped, we can restore `encoding: utf8mb4` in database.yml
2018-10-30 12:17:48 +00:00
Ryuta Kamizono f5ddf81784 Exercise HABTM fixtures with foreign key constraints 2018-10-30 11:08:41 +09:00
Akira Matsuda ad3669ee11 We don't want these internal methods as public methods in our controllers
or they would be listed in `action_methods`
2018-10-30 10:23:26 +09:00
Akira Matsuda ae30b9b885 Missing require "active_support/executor" 2018-10-30 10:17:09 +09:00
Akira Matsuda ee470cefc0 Missing require "core_ext/module/attribute_accessors" 2018-10-30 10:17:09 +09:00
Akira Matsuda b36c3956d6 Missing require "active_support/concern" 2018-10-30 10:17:09 +09:00
Ryuta Kamizono d7f48c9c39
Merge pull request #34338 from malclocke/document_exception_class_for_restrict_with_exception
Document exception from restrict_with_exception [ci skip]
2018-10-30 00:16:30 +09:00
James Le Cuirot cf1d75d95d Avoid violating key constraints in fixture HABTM associations
When loading fixtures, Ruby 1.9's hash key ordering means that HABTM
join table rows are always loaded before the parent table rows,
violating foreign key constraints that may be in place. This very
simple change ensures that the parent table's key appears first in the
hash. Violations may still occur if fixtures are loaded in the wrong
order but those instances can be avoided unlike this one.
2018-10-29 15:11:35 +00:00
Malcolm Locke 20ea01bd64 Document exception from restrict_with_exception [ci skip] 2018-10-29 15:12:29 +13:00
Ryuta Kamizono 0d68e0690f
Merge pull request #34335 from robin850/update-bug-report-templates
Update bug report templates
2018-10-29 11:03:15 +09:00
Ryuta Kamizono 0bd4894d8b
Merge pull request #34334 from albertoalmagro/privatize-constants-activesupport-timezone
Privatize and add # :nodoc: to constants
2018-10-29 10:45:28 +09:00
Xavier Noria d3cf5d25fc Registers e302725 in the CHANGELOG [ci skip]
References #34253.
2018-10-28 19:44:16 +01:00
Robin Dupret a2f44cc377
Merge pull request #34333 from albertoalmagro/fix-activemodel-dirty-changed-doc
Fix grammar in changed? docs [ci skip]
2018-10-28 18:28:20 +01:00
Robin Dupret f1e4d3d8dd Update bug report templates
Given that Bundler 1.10 was released back in 2015, we can assume
that people are at least on this version or a higher one so there
is no need to ask people to upgrade.

Also, given that Rails 5.0 supports Ruby 2.2+ and given that this
version come with Minitest 5.4.3 bundled, we don't need to ensure
backward compatibility with Minitest 4.
2018-10-28 18:12:48 +01:00
Alberto Almagro 3d137b3a12 Privatize and add # :nodoc: to constants
Both `UTC_OFFSET_WITH_COLON` and `UTC_OFFSET_WITHOUT_COLON` are only
used within `ActiveSupport::TimeZone` and in my opinion they do not
provide relevant information that should appear in the docs.
2018-10-28 17:51:22 +01:00
Alberto Almagro 8d54f3ebaa Fix grammar in changed? docs [ci skip]
See https://english.stackexchange.com/questions/23218/anyone-has-or-anyone-have-seen-them
2018-10-28 17:20:27 +01:00
Xavier Noria 7d7372c14d
Merge pull request #34253 from haberbyte/fix_autoload_on_activestorage_downloader
Fix autoloading issue with ActiveStorage::Downloader
2018-10-28 17:16:24 +01:00
Jan Habermann e302725751 Improve the logic that detects non-autoloaded constants
If you require `nokogiri` from `app/models/user.rb`, dependencies.rb
does not mark `Nokogiri` as an autoloaded constant, as expected.
But the logic to detect these non-autoloaded constants is incomplete.
See the tests defined in the patch for some cases incorrectly handled.
2018-10-28 16:34:50 +01:00
Olivier Lacan 3295e23755 Use release dates for versions in Rails Guides index
We repeat the phrase "Release Notes" even though release note are listed
under a... "Release Notes" category already. With this change, instead
of repeating ourselves, we can give people a sense of the recency of
each release by simply listing the month and year of each release.

This is a follow-up to #34265 as suggested by @jeremy.

[ci skip]
2018-10-27 10:49:31 -05:00
Ryuta Kamizono 09b7308c48 `exists?` with string argument is not invalid type
Any type can be a primary key, so blank string is also valid value.

Closes #26356.
2018-10-27 23:20:13 +09:00
Ryuta Kamizono 7fae9ba054 `create_table` with `:primary_key` option has no effect if `id: false` is given
Use column definition with `primary_key: true` instead.
2018-10-27 22:57:16 +09:00
Ryuta Kamizono 6c98dad59d
Merge pull request #34329 from r7kamura/feature/where-exclamation-consistency
Ignore empty condition on #construct_relation_for_exists
2018-10-27 22:45:29 +09:00
r7kamura 4694fcf413 Ignore empty condition on #construct_relation_for_exists
At fc0e3354af,

```rb
relation = relation.where(conditions)
```

was rewritten to:

```rb
relation.where!(condition)
```

This change accidentally changed the result of `Topic.exists?({})` from true to false.

To fix this regression, first I moved the blank check logic (`opts.blank?`) from `#where` to `#where!`,
because I thought `#where!` should be identical to `#where`, except that instead of returning a new relation,
it adds the condition to the existing relation.

But on second thought after some discussion on https://github.com/rails/rails/pull/34329,
I started to think that just fixing `#construct_relation_for_exists` is more preferable
than changing `#where` and `#where!`.
2018-10-27 21:53:11 +09:00
Gannon McGibbon abf51844bb Add support for hash and url configs in connected_to
Add support for hash and url configs in database hash
of `ActiveRecord::Base.connected_to`.
2018-10-26 16:27:25 -04:00
Eileen M. Uchitelle 5431e17733
Merge pull request #34266 from esquith/improve-no-response-file-wording
Improve no-response file wording
2018-10-26 10:00:18 -04:00
Ryuta Kamizono 61490805fe
Merge pull request #34208 from yskkin/inspect_with_parameter_filter
Implement AR#inspect using ParameterFilter
2018-10-26 19:05:34 +09:00
Ryuta Kamizono 9e9e2b7f71
Merge pull request #34307 from kamipo/mysql_expression_support
Support default expression and expression indexes for MySQL
2018-10-26 18:51:16 +09:00
Ryuta Kamizono e7c44ee439
Merge pull request #34318 from bogdanvlviv/partly-revert-31819
Partly revert #31819
2018-10-26 10:44:47 +09:00
bogdanvlviv bf6dc7a714
Partly revert #31819
The PR#31819 changed `#preloaders_on` and added some test,
then #33938 reverted changes that were added to the method in #31819.
Since changes in the method were reverted and as mentioned in the
comment https://github.com/rails/rails/pull/31819#discussion_r221847481
that titles of the tests added in #31819 don't reflect implementation I
think we can remove those test for now.
2018-10-26 00:48:47 +03:00
Gannon McGibbon 3f8b1353c6
Merge pull request #34313 from GeniusStorm/add_maxlength_to_textfield_doc
Add maxlength attribute usage example to Text Field Api documentation
2018-10-25 16:36:37 -04:00
Rafael França c4fd38a206
Merge pull request #34317 from bogdanvlviv/fix-assert_called_with
`assert_called_with` should require `args` argument
2018-10-25 16:20:47 -04:00
Raghu Kamat 5edbc1fd20 Added maxlength example to text_field documentation
The usage of maxlength in the text_field helper adds a size attribute
to the generated text_field input with the same value as the maxlength.
This implicit addition of size attribute by the method gives a false
impression that it may be bug. By adding the implementation of the
maxlength to the api docs, we explicitly tell the reader referring the
api doc that addition of size along with maxlength is the expected behaviour.

[ci skip]
2018-10-25 16:00:59 -04:00
bogdanvlviv 9d0cf52096
`assert_called_with` should require `args` argument
There are two main reasons why `assert_called_with` should require
`args` argument:

1) If we want to assert that some method should be called and we don't
   need to check with which arguments it should be called then we should use
   `assert_called`.

2) `assert_called_with` without `args` argument doesn't assert anything!
   ```ruby
   assert_called_with(@object, :increment) do
      @object.decrement
   end
   ```
   It causes false assertions in tests that could cause regressions in the project.

I found this bug by working on
[minitest-mock_expectations](https://github.com/bogdanvlviv/minitest-mock_expectations) gem.
This gem is an extension for minitest that provides almost the same method call
assertions.
I was wondering whether you would consider adding "minitest-mock_expectations"
to `rails/rails` instead of private `ActiveSupport::Testing::MethodCallAssertions` module.
If yes, I'll send a patch - a970ecc42c
2018-10-25 21:29:39 +03:00
Benjamin Fleischer 170cb2ee9b
ActionController::API *does* support cookies, sessions
ActionController::Metal provides session support by delegating `session  to the request (`"@_request"`)
a3dcba42e2/actionpack/lib/action_controller/metal.rb (L149)

Though the ActionController::Cookies modules isn't included, it's really a convenience for providing a first class `cookies` object.

*all* ActionController::Metal subclasses support setting cookies via the `session` object.
2018-10-25 10:36:39 -05:00
Eileen M. Uchitelle a3dcba42e2
Merge pull request #34309 from oliverguenther/patch-1
Document `deep_interpolation` parameter for bulk lookups
2018-10-25 08:09:01 -04:00
Ryuta Kamizono a2ad8f456e Support default expression for MySQL
MySQL 8.0.13 and higher supports default value to be a function or
expression.

https://dev.mysql.com/doc/refman/8.0/en/create-table.html
2018-10-25 18:11:22 +09:00
Ryuta Kamizono d496055b5b Support expression indexes for MySQL
MySQL 8.0.13 and higher supports functional key parts that index
expression values rather than column or column prefix values.

https://dev.mysql.com/doc/refman/8.0/en/create-index.html
2018-10-25 18:09:02 +09:00
Oliver Günther 4692ed7e12
Document `deep_interpolation` parameter for bulk lookups
Bulk lookups are sort of an edge case, I have not heard of them until a colleague of mine decided to dynamically iterate over a growing set of translations and receiving them in bulk as a hash with `I18n.t 'welcome'` as in the example above.

When passing an interpolation to these bulk lookups, they will only be performed when also passing `deep_interpolation: true`.

**Without passing `deep_interpolation` flag:**
```ruby
I18n.t 'welcome', app_name: 'book store'
# => {:title=>"Welcome!", :content=>"Welcome to the %{app_name}"}

**With passing `deep_interpolation`:**
I18n.t 'welcome', deep_interpolation: true, app_name: 'book store'
# => {:title=>"Welcome!", :content=>"Welcome to the book store"}
```

I found this digging in the I18n lookup backend, the flag is listed on [I18n's Rubydoc](https://www.rubydoc.info/github/svenfuchs/i18n/master/I18n) but not otherwise listed. Since bulk lookups are mentioned here, I suggest to add a note with this flag along with it.
2018-10-25 07:46:58 +02:00
Ryuta Kamizono 3c00087394 Deterministic connection collation in tests
The default collation for utf8mb4 is changed to utf8mb4_0900_ai_ci in
MySQL 8.0, so `test_mysql_connection_collation_is_configured` is
affected by MySQL version and/or default_collation_for_utf8mb4 system
variable.

https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_collation_for_utf8mb4

```
% ARCONN=mysql2 be ruby -w -Itest test/cases/adapters/mysql2/connection_test.rb -n test_mysql_connection_collation_is_configured
Using mysql2
Run options: -n test_mysql_connection_collation_is_configured --seed 10421

# Running:

F

Failure:
Mysql2ConnectionTest#test_mysql_connection_collation_is_configured [test/cases/adapters/mysql2/connection_test.rb:108]:
Expected: "utf8mb4_general_ci"
  Actual: "utf8mb4_0900_ai_ci"

rails test test/cases/adapters/mysql2/connection_test.rb:106

Finished in 0.013842s, 72.2450 runs/s, 144.4900 assertions/s.
1 runs, 2 assertions, 1 failures, 0 errors, 0 skips
```
2018-10-25 10:50:27 +09:00
Rafael França d76d66fb55
Merge pull request #34204 from XrXr/aj-test-helper-args
Include deserialized arguments in jobs returned by AJ test helpers
2018-10-24 15:49:10 -04:00
Rafael França d3e646595f
Merge pull request #34303 from kamipo/lazy_checking_boundable
Lazy checking whether or not values in IN clause are boundable
2018-10-24 12:53:37 -04:00
Gannon McGibbon eba2ba8d3a
Merge pull request #34034 from runephilosof/patch-2
Make it easier to find abort documentation
2018-10-24 11:48:35 -04:00
Robin Dupret 46c2a86579
Merge pull request #34302 from kylekeesling/activestorage-attachment-model-docs
Update ActiveStorage Attachment model documentation [ci skip]
2018-10-24 15:35:30 +02:00
Kyle Keesling 79e086efc4
update activestorage attachment model documentation reflect recent behavior changes 2018-10-24 09:08:45 -04:00
Ryuta Kamizono ce40073c9c Lazy checking whether or not values in IN clause are boundable
Since #33844, eager loading/preloading with too many and/or too large
ids won't be broken by pre-checking whether the value is constructable
or not.

But the pre-checking caused the type to be evaluated at relation build
time instead of at the query execution time, that is breaking an
expectation for some apps.

I've made the pre-cheking lazy as much as possible, that is no longer
happend at relation build time.
2018-10-24 11:26:49 +09:00