- 11 10月, 2018 3 次提交
-
-
由 Yoshiyuki Kinjo 提交于
-
由 Eileen M. Uchitelle 提交于
Part 4: Multi db improvements, Basic API for connection switching
-
由 Eileen Uchitelle 提交于
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 ```
-
- 10 10月, 2018 20 次提交
-
-
由 Eileen M. Uchitelle 提交于
Enum raises on invalid definition values
-
由 Eileen M. Uchitelle 提交于
Add multi-db support to rails db:migrate:status
-
由 Eileen M. Uchitelle 提交于
Follow up #34064
-
由 Eileen M. Uchitelle 提交于
Add allocations to template renderer subscription
-
由 Eileen Uchitelle 提交于
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) ```
-
由 Alberto Almagro 提交于
-
由 Alberto Almagro 提交于
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
-
由 Ryuta Kamizono 提交于
Generate delegation methods to named scope in the definition time
-
由 Ryuta Kamizono 提交于
Fix inconsistent behavior by clearing QueryCache when reloading associations
-
由 Ryuta Kamizono 提交于
Follow up 45be690f. `predicate_builder.build` in `where` requires `load_schema` for `type_for_attribute`.
-
由 Christophe Maximin 提交于
-
由 Ryuta Kamizono 提交于
-
由 Ryuta Kamizono 提交于
-
由 Gannon McGibbon 提交于
-
由 Ryuta Kamizono 提交于
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"]] ```
-
由 Eileen M. Uchitelle 提交于
Add `skip-webpack-install` option
-
由 Gannon McGibbon 提交于
Change contributing guide to suggest using safer force push
-
由 Eileen M. Uchitelle 提交于
Move db:migrate:status to DatabaseTasks method
-
由 Gannon McGibbon 提交于
clarify role of unique_id in ActiveSupport::Notifications [ci skip]
-
由 Ryuta Kamizono 提交于
Add docs to ActiveRecord::Persistence#belongs_to_touch_method [ci skip]
-
- 09 10月, 2018 6 次提交
-
-
由 Ryuta Kamizono 提交于
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.
-
由 yuuji.yaginuma 提交于
To remove extra `--no-skip-javascript` tests.
-
由 yuuji.yaginuma 提交于
`webpacker:install` also includes execution of yarn, it takes time to execute, so avoid unnecessary tests.
-
由 yuuji.yaginuma 提交于
This option is useful when want to check only the files generated by `rails new`, or if want to do something before `webpacker:install`.
-
由 Ryuta Kamizono 提交于
Follow up 45be690f. 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`.
-
由 Gannon McGibbon 提交于
-
- 08 10月, 2018 11 次提交
-
-
由 Ryuta Kamizono 提交于
fix broken link in Action Cable guides and readme [ci skip]
-
由 Donnie Propst 提交于
-
由 George Claghorn 提交于
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*.
-
由 Greg Molnar 提交于
-
由 Graham Conzett 提交于
-
由 Ryuta Kamizono 提交于
respect only_path option when an array is passed into url_for
-
由 Ryuta Kamizono 提交于
Deprecate ActionDispatch::Http::ParameterFilter in favor of ActiveSup…
-
由 Arun Agrawal 提交于
[ci skip] Fix typo
-
由 Francesco Rodríguez 提交于
-
由 Yoshiyuki Kinjo 提交于
-
由 Chris Fung 提交于
[ci skip]
-