aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* | | | 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.
| * | | | | | Avoid `webpacker:install` if unnecessaryyuuji.yaginuma2018-10-093-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `webpacker:install` also includes execution of yarn, it takes time to execute, so avoid unnecessary tests.
| * | | | | | Add `skip-webpack-install` optionyuuji.yaginuma2018-10-093-1/+22
| | |/ / / / | |/| | | | | | | | | | | | | | | | | | | | | | This option is useful when want to check only the files generated by `rails new`, or if want to do something before `webpacker:install`.
* | | | | | Merge pull request #34075 from hakusaro/guides-reference-leasesGannon McGibbon2018-10-091-6/+7
|\ \ \ \ \ \ | | | | | | | | | | | | | | Change contributing guide to suggest using safer force push
| * | | | | | Change contributing guide to use safer force pushLucas Nicodemus2018-10-041-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit changes the contributing guide in rails to suggest using git with force-with-lease over typical force pushing. In practice, most rails contributors won't ever encounter a situation where updating their local fork could result in lost changes as a result of a force push. That being said, git is a complex tool and arcane flags like force-with-lease are indeed safer, and by promoting it in rails, there's a chance more people will discover it and use it in other contexts outside of rails. In just the same way that herd immunity works by most people being vaccinated, proliferating knowledge of force-with-lease should help nudge people towards using safer git commands in general. [ci skip]
* | | | | | | Merge pull request #34081 from gmcgibbon/db_migrate_status_moveEileen M. Uchitelle2018-10-093-13/+39
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | Move db:migrate:status to DatabaseTasks method
| * | | | | | | Move db:migrate:status to DatabaseTasks methodGannon McGibbon2018-10-083-13/+39
| | | | | | | |
* | | | | | | | Merge pull request #34105 from zvkemp/correct-asn-docsGannon McGibbon2018-10-092-4/+5
|\ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | clarify role of unique_id in ActiveSupport::Notifications [ci skip]
| * | | | | | | | clarify role of unique_id in ActiveSupport::Notificationszvkemp2018-10-052-4/+5
| | | | | | | | |
* | | | | | | | | Merge pull request #34117 from ↵Ryuta Kamizono2018-10-101-0/+2
|\ \ \ \ \ \ \ \ \ | |_|_|_|/ / / / / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | aergonaut/docs/ActiveRecord--Persistence-belongs_to_touch_method Add docs to ActiveRecord::Persistence#belongs_to_touch_method [ci skip]
| * | | | | | | | Add docs to ActiveRecord::Persistence#belongs_to_touch_methodChris Fung2018-10-071-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | [ci skip]
* | | | | | | | | Call `define_attribute_methods` before `assert_no_queries` to address CI ↵Ryuta Kamizono2018-10-095-9/+80
| |_|/ / / / / / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | flakiness Follow up 45be690f8e6db019aac6198ba49d608a2e14824b. Somehow calling `define_attribute_methods` in `build`/`new` sometimes causes the `table_exists?` query. To address CI flakiness due to `assert_no_queries` failure, ensure `define_attribute_methods` before `assert_no_queries`.
* | | | | | | | Merge pull request #34126 from gregmolnar/guide-link-fixRyuta Kamizono2018-10-092-2/+2
|\ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | fix broken link in Action Cable guides and readme [ci skip]
| * | | | | | | | fix broken link in Action Cable guides and readme [ci skip]Greg Molnar2018-10-082-2/+2
| | | | | | | | |
* | | | | | | | | Point to requiring the ASt engine in the installation instructions [ci skip]Donnie Propst2018-10-081-0/+2
| | | | | | | | |
* | | | | | | | | Fix directly uploading using a MIME type synonymGeorge Claghorn2018-10-082-1/+11
|\ \ \ \ \ \ \ \ \ | |/ / / / / / / / |/| | | | | | | | | | | | | | | | | | | | | | | | | | When Content-Type is "application/x-gzip", request.content_type resolves to "application/gzip", because application/x-gzip is a synonym of application/gzip by default. This causes the acceptable_content? check in ActiveStorage::DiskController to fail, because the direct upload token contains application/x-gzip, which is not equal to application/gzip. Fix by comparing the token content type with the request content type *and its synonyms*.