aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Add regression test against habtm memoized singular_idsAlberto Almagro2018-10-161-0/+12
| | | | | | | | | | | | | | | Starting in Rails 5.0.0 and still present in Rails 5.2.1, `singular_ids` got memoized and didn't reload after more items were added to the relation. Although 19c8071 happens to fix the issue, it only adds tests for `has_many` relations while this bug only affected `has_and_belongs_to_many` relations. This commit adds a regression test to ensure it never happens again with `habtm` relations. Ensures #34179 never gets reproduced.
* Merge pull request #29204 from ↵Ryuta Kamizono2018-10-164-5/+21
|\ | | | | | | | | | | RasPat1/issue-29200-scaffold-reference-display-memory-address Issue #29200 scaffold an object with a reference displays an object memory address to user
| * Show object ids in scaffold pages when displaying referenced objectsRasesh Patel2018-10-144-5/+20
| | | | | | | | | | | | | | | | | | | | | | | | Resolve Issue#29200 When scaffolding a model that references another model the generated show and index html pages display the object directly on the page. Basically, it just shows a memory address. That is not very helpful. In this commit we show the object's id rather than the memory address. This updates the scaffold templates and the json builder files.
* | Merge pull request #33075 from ↵Ryuta Kamizono2018-10-163-2/+22
|\ \ | | | | | | | | | | | | | | | fedxgibson/pg_ambigous_column_cache_key_limit_custom_select Fix Collection cache key with limit and custom select
| * | Fix Collection cache key with limit and custom select (PG:AmbigousColumn: Error)Federico Martinez2018-10-153-2/+22
|/ / | | | | | | Change query to use alias name for timestamp_column to avoid ambiguity problems when using timestamp from subquery.
* | Deprecate ActiveSupport::Multibyte::Chars.consumes?Francesco Rodríguez2018-10-153-3/+18
| | | | | | | | | | | | In favor of String#is_utf8?. I think this method was made for internal use only, and its usage was removed here: https://github.com/rails/rails/pull/8261/files#diff-ce956ebe93786930e40f18db1da5fd46L39.
* | Merge pull request #34214 from brasscapon/rails_fiveRyuta Kamizono2018-10-151-1/+1
|\ \ | | | | | | | | | | | | Update snippet to rails 5 syntax [ci skip]
| * | Update snippet to rails 5 syntaxAdam Demirel2018-10-151-1/+1
| | |
* | | Fix `ActionController::Parameters#each_value` and add changelog entry to ↵Bogdan2018-10-153-3/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | this method (#34210) * Fix `ActionController::Parameters#each_value` `each_value` should yield with "value" of the params instead of "value" as an array. Related to #33979 * Add changelog entry about `ActionController::Parameters#each_value`. Follow up #33979
* | | Merge pull request #34135 from Edouard-chin/ec-rounded-durationAndrew White2018-10-153-3/+12
|\ \ \ | | | | | | | | Fix issue where duration where always rounded up to a second:
| * | | Fix issue where duration where always rounded up to a second:Edouard CHIN2018-10-123-3/+12
| | |/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Adding a Float as a duration to a datetime would result in the Float being rounded. Doing something like would have no effect because the 0.45 seconds would be rounded to 0 second. ```ruby time = DateTime.parse("2018-1-1") time += 0.45.seconds ``` This behavior was intentionally added a very long time ago, the reason was because Ruby 1.8 was using `Integer#gcd` in the constructor of Rational which didn't accept a float value. That's no longer the case and doing `Rational(0.45, 86400)` would now perfectly work fine. - Fixes #34008
* | | Ensure to test that `project.developers` is ordered by `developers.name desc`Ryuta Kamizono2018-10-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | `developers.name desc` was added at d59f3a7, but any test case isn't failed even if the `developers.name desc` is removed since all tested developers are consistently ordered on both `name` and `id`. I changed one developers creation ordering to ensure to test that `project.developers` is ordered by `developers.name desc`.
* | | Merge pull request #34209 from y-yagi/fix_tests_on_mail_271Yuji Yaginuma2018-10-152-5/+5
|\ \ \ | |/ / |/| | Fix tests on Mail 2.7.1
| * | Fix tests on Mail 2.7.1yuuji.yaginuma2018-10-141-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Up to `2.7.0`, encoding was chosen using `Mail::Encodings::TransferEncoding.negotiate`, and base64 encoding was used. In `2.7.1`, when `transfer_encoding` is not specified, the encoding of the message is respected. Related to: https://github.com/mikel/mail/commit/dead487e02f592d9058fd07deedcde39b569d18d However, what chosen for transfer encoding is not essential in these tests. To test more accurately, confirm that the decoded body instead.
| * | Bump mail to `2.7.1`yuuji.yaginuma2018-10-141-1/+1
|/ /
* | Improve model attribute accessor method names for backtracesDylan Thacker-Smith2018-10-125-75/+69
| | | | | | | | | | | | | | | | Ruby uses the original method name, so will show the __temp__ method name in the backtrace. However, in the common case the method name is compatible with the `def` keyword, so we can avoid the __temp__ method name in that case to improve the name shown in backtraces or TracePoint#method_id.
* | Deprecate Unicode#normalize and Chars#normalize (#34202)Francesco Rodríguez2018-10-127-122/+212
| |
* | Merge pull request #34123 from frodsan/deprecate_unicode_string_wrappersJeremy Daer2018-10-124-41/+23
|\ \ | | | | | | Deprecate Unicode#downcase/upcase/swapcase.
| * | Use native String#capitalizeFrancesco Rodríguez2018-10-122-9/+2
| | |
| * | Deprecate Unicode#downcase/upcase/swapcase.Francesco Rodríguez2018-10-124-33/+22
| | | | | | | | | | | | Use String methods directly instead.
* | | Runs the generator before assertionsyuuji.yaginuma2018-10-121-0/+1
|/ /
* | Test that nested structs to_json works as expectedEileen Uchitelle2018-10-111-0/+10
| | | | | | | | | | Check that options passed to the to_json are passed to all objects that respond to as_json.
* | Merge pull request #34185 from gmcgibbon/test_retryRafael França2018-10-114-2/+9
|\ \ | |/ |/| Add test retries for railties
| * Include test gems in CIGannon McGibbon2018-10-111-1/+1
| |
| * Add test retries for railtiesGannon McGibbon2018-10-113-1/+8
|/
* Merge pull request #34189 from orhantoy/fix-link-to-concurrent-ruby-docsKasper Timm Hansen2018-10-111-1/+1
|\ | | | | [ci skip] Fix link to Concurrent::ThreadPoolExecutor docs
| * [ci skip] Fix link to Concurrent::ThreadPoolExecutor docsOrhan Toy2018-10-111-1/+1
|/
* Merge pull request #34188 from yskkin/remove_commentRyuta Kamizono2018-10-111-2/+0
|\ | | | | Remove invalid magic comment [ci skip]
| * Remove invalid magic comment [ci skip]Yoshiyuki Kinjo2018-10-111-2/+0
|/
* Merge pull request #34052 from eileencodes/connection-switchingEileen M. Uchitelle2018-10-104-1/+328
|\ | | | | Part 4: Multi db improvements, Basic API for connection switching
| * Basic API for connection switchingEileen Uchitelle2018-10-104-1/+328
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This PR adds the ability to 1) connect to multiple databases in a model, and 2) switch between those connections using a block. To connect a model to a set of databases for writing and reading use the following API. This API supercedes `establish_connection`. The `writing` and `reading` keys represent handler / role names and `animals` and `animals_replica` represents the database key to look up the configuration hash from. ``` class AnimalsBase < ApplicationRecord connects_to database: { writing: :animals, reading: :animals_replica } end ``` Inside the application - outside the model declaration - we can switch connections with a block call to `connected_to`. If we want to connect to a db that isn't default (ie readonly_slow) we can connect like this: Outside the model we may want to connect to a new database (one that is not in the default writing/reading set) - for example a slow replica for making slow queries. To do this we have the `connected_to` method that takes a `database` hash that matches the signature of `connects_to`. The `connected_to` method also takes a block. ``` AcitveRecord::Base.connected_to(database: { slow_readonly: :primary_replica_slow }) do ModelInPrimary.do_something_thats_slow end ``` For models that are already loaded and connections that are already connected, `connected_to` doesn't need to pass in a `database` because you may want to run queries against multiple databases using a specific role/handler. In this case `connected_to` can take a `role` and use that to swap on the connection passed. This simplies queries - and matches how we do it in GitHub. Once you're connected to the database you don't need to re-connect, we assume the connection is in the pool and simply pass the handler we'd like to swap on. ``` ActiveRecord::Base.connected_to(role: :reading) do Dog.read_something_from_dog ModelInPrimary.do_something_from_model_in_primary end ```
* Merge pull request #34110 from ↵Eileen M. Uchitelle2018-10-103-0/+33
|\ | | | | | | | | albertoalmagro/enum-raises-on-invalid-definition-values Enum raises on invalid definition values
| * Privatize ENUM_CONFLICT_MESSAGE constantAlberto Almagro2018-10-101-0/+1
| |
| * Raise on invalid definition valuesAlberto Almagro2018-10-103-0/+32
| | | | | | | | | | | | | | | | | | When defining a Hash enum it can be easy to use [] instead of {}. This commit checks that only valid definition values are provided, those can be a Hash, an array of Symbols or an array of Strings. Otherwise it raises an ArgumentError. Fixes #33961
* | Merge pull request #34137 from gmcgibbon/db_migrate_status_multi_dbEileen M. Uchitelle2018-10-103-20/+71
|\ \ | | | | | | Add multi-db support to rails db:migrate:status
| * | Add multi-db support to rails db:migrate:statusGannon McGibbon2018-10-093-20/+71
| | |
* | | Merge pull request #34109 from bogdanvlviv/follow-up-34064Eileen M. Uchitelle2018-10-101-21/+0
|\ \ \ | | | | | | | | Follow up #34064
| * | | Follow up #34064bogdanvlviv2018-10-061-21/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The removed code was added in 7f870a5ba2aa9177aa4a0e03a9d027928ba60e49, then 7f870a5ba2aa9177aa4a0e03a9d027928ba60e49 was reverted by #34064. But I found that that commit wasn't completely reverted, I guess it was caused by resolving some conflicts during reverting. @schneems could you please confirm that those changes weren't reverted unintentionally, or reject this commit otherwise?
* | | | Merge pull request #34136 from rails/add-allocations-to-template-rendererEileen M. Uchitelle2018-10-105-12/+27
|\ \ \ \ | |_|_|/ |/| | | Add allocations to template renderer subscription
| * | | Add allocations to template renderer subscriptionEileen Uchitelle2018-10-105-12/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This PR adds the allocations to the instrumentation for template and partial rendering. Before: ``` Rendering posts/new.html.erb within layouts/application Rendered posts/_form.html.erb (9.7ms) Rendered posts/new.html.erb within layouts/application (10.9ms) Completed 200 OK in 902ms (Views: 890.8ms | ActiveRecord: 0.8ms) ``` After: ``` Rendering posts/new.html.erb within layouts/application Rendered posts/_form.html.erb (Duration: 7.1ms | Allocations: 6004) Rendered posts/new.html.erb within layouts/application (Duration: 8.3ms | Allocations: 6654) Completed 200 OK in 858ms (Views: 848.4ms | ActiveRecord: 0.4ms | Allocations: 1539564) ```
* | | | Merge pull request #34122 from kamipo/generate_relation_methodsRyuta Kamizono2018-10-106-5/+59
|\ \ \ \ | | | | | | | | | | Generate delegation methods to named scope in the definition time
| * | | | Generate delegation methods to named scope in the definition timeRyuta Kamizono2018-10-096-5/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The delegation methods to named scope are defined when `method_missing` is invoked on the relation. Since #29301, the receiver in the named scope is changed to the relation like others (e.g. `default_scope`, etc) for consistency. Most named scopes would be delegated from relation by `method_missing`, since we don't allow scopes to be defined which conflict with instance methods on `Relation` (#31179). But if a named scope is defined with the same name as any method on the `superclass` (e.g. `Kernel.open`), the `method_missing` on the relation is not invoked. To address the issue, make the delegation methods to named scope is generated in the definition time. Fixes #34098.
* | | | | Merge pull request #34094 from ↵Ryuta Kamizono2018-10-107-3/+111
|\ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | christophemaximin/fix-activerecord-clearing-of-query-cache Fix inconsistent behavior by clearing QueryCache when reloading associations
| * | | | | Clear QueryCache when reloading associationsChristophe Maximin2018-10-107-3/+111
| | | | | |
* | | | | | Call `load_schema` before `assert_no_queries`Ryuta Kamizono2018-10-101-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Follow up 45be690f8e6db019aac6198ba49d608a2e14824b. `predicate_builder.build` in `where` requires `load_schema` for `type_for_attribute`.
* | | | | | Fix odd indentationRyuta Kamizono2018-10-101-10/+10
| | | | | |
* | | | | | Refactor Arel visitor to use `collect_nodes_for` as much as possibleRyuta Kamizono2018-10-101-33/+10
| |_|_|_|/ |/| | | |
* | | | | Improve DELETE with JOIN handling to avoid subqueries if possibleRyuta Kamizono2018-10-102-9/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before: ``` Pet Destroy (0.8ms) DELETE FROM `pets` WHERE `pets`.`pet_id` IN (SELECT `pet_id` FROM (SELECT DISTINCT `pets`.`pet_id` FROM `pets` LEFT OUTER JOIN `toys` ON `toys`.`pet_id` = `pets`.`pet_id` WHERE `toys`.`name` = ?) AS __active_record_temp) [["name", "Bone"]] ``` After: ``` Pet Destroy (1.0ms) DELETE `pets` FROM `pets` LEFT OUTER JOIN `toys` ON `toys`.`pet_id` = `pets`.`pet_id` WHERE `toys`.`name` = ? [["name", "Bone"]] ```
* | | | | Merge pull request #34071 from y-yagi/skip_webpacker_installEileen M. Uchitelle2018-10-096-8/+30
|\ \ \ \ \ | |_|_|/ / |/| | | | Add `skip-webpack-install` option
| * | | | Use `--skip-webpack-install` by defaultyuuji.yaginuma2018-10-093-7/+7
| | | | | | | | | | | | | | | | | | | | To remove extra `--no-skip-javascript` tests.