- 10 10月, 2018 1 次提交
-
-
由 Christophe Maximin 提交于
-
- 09 10月, 2018 2 次提交
-
-
由 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.
-
由 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`.
-
- 07 10月, 2018 2 次提交
-
-
由 Ryuta Kamizono 提交于
-
由 Ryuta Kamizono 提交于
Since #31575, `set_inverse_instance` replaces the foreign key by the current owner immediately to make it happen when a record is added to collection association. But `set_inverse_instance` is not only called when a record is added, but also when a record is loaded from queries. And also, that loaded records are not always associated records for some reason (using `or`, `unscope`, `rewhere`, etc). It is hard to distinguish whether or not we should invoke `set_inverse_instance`, but at least we should avoid the undesired side-effect which was brought from #31575. Fixes #34108.
-
- 05 10月, 2018 2 次提交
-
-
由 Ryuta Kamizono 提交于
Follow up 811be477.
-
由 Ryuta Kamizono 提交于
`test_update_does_not_run_sql_if_record_has_not_changed` would pass without #18501 since `assert_queries` ignores BEGIN/COMMIT unless `ignore_none: true` is given. Since #32647, empty BEGIN/COMMIT is ommited. So we no longer need to use `assert_queries(0)` to ignore BEGIN/COMMIT in the queries.
-
- 26 9月, 2018 2 次提交
-
-
由 Ryuta Kamizono 提交于
This reverts commit 376ffe0e. Since 38fae1f2, `association.increment_counters` is called without inflated parent target if inverse_of is disabled. In that case, that commit would cause extra queries to inflate parent.
-
由 Ryuta Kamizono 提交于
Fixes #19550.
-
- 25 8月, 2018 2 次提交
-
-
由 Ryuta Kamizono 提交于
-
由 Rich 提交于
There is test in has_one to test enum, but there is no for has_many. [Rich Chen]
-
- 13 8月, 2018 1 次提交
-
-
由 utilum 提交于
Six Mocha calls prove quite resistant to Minitestification. For example, if we replace ``` ActiveRecord::Associations::HasManyAssociation .any_instance .expects(:reader) .never ``` with `assert_not_called`, Minitest wisely raises ``` NameError: undefined method `reader' for class `ActiveRecord::Associations::HasManyAssociation' ``` as `:reader` comes from a deeply embedded abstract class, `ActiveRecord::Associations::CollectionAssociation`. This patch tackles this difficulty by adding `ActiveSupport::Testing::MethodCallAsserts#assert_called_on_instance_of` which injects a stubbed method into `klass`, and verifies the number of times it is called, similar to `assert_called`. It also adds a convenience method, `assert_not_called_on_instance_of`, mirroring `assert_not_called`. It uses the new method_call_assertions to replace the remaining Mocha calls in `ActiveRecord` tests. [utilum + bogdanvlviv + kspath]
-
- 07 6月, 2018 1 次提交
-
-
由 Ryuta Kamizono 提交于
In `_create_record`, explicit `transaction` block requires rollback handling manually when `insert_record` is failed. We need to handle it in `_create_record`, not in `insert_record`, since our test cases expect a record added to target and returned even if `insert_record` is failed, Closes #31488.
-
- 13 5月, 2018 1 次提交
-
-
由 Ryuta Kamizono 提交于
Follow up of #32605.
-
- 27 4月, 2018 2 次提交
-
-
由 Ryuta Kamizono 提交于
Currently `ids_reader` doesn't respect dirty target when the target is not loaded yet unlike `collection.size`. I believe the inconsistency is a bug, fixes the `ids_reader` to behave consistently regardless of whether target is loaded or not.
-
由 Graham Turner 提交于
Already loaded associations were running an extra query when `size` was called on the association. This fix ensures that an extra query is no longer run. Update tests to use proper methods
-
- 26 4月, 2018 2 次提交
- 21 4月, 2018 1 次提交
-
-
由 Ryuta Kamizono 提交于
-
- 19 4月, 2018 1 次提交
-
-
由 Daniel Colson 提交于
This autocorrects the violations after adding a custom cop in 3305c78dcd.
-
- 30 3月, 2018 1 次提交
-
-
- 18 2月, 2018 2 次提交
-
-
由 Ryuta Kamizono 提交于
3acc5d6e was changed the order of scope evaluation from through scope to the association's own scope to be prioritized over the through scope. But the sorting order will be prioritized that is evaluated first. It is unintentional effect, association scope's sorting order should be prioritized as well. Fixes #32008.
-
由 Eddie Lebow 提交于
Closes #31998
-
- 26 1月, 2018 3 次提交
-
-
由 Daniel Colson 提交于
-
由 Daniel Colson 提交于
-
由 Daniel Colson 提交于
-
- 27 12月, 2017 1 次提交
-
-
由 Bogdan Gusiev 提交于
when model is added to collection association
-
- 12 12月, 2017 1 次提交
-
-
由 Ryuta Kamizono 提交于
Follow up of #31390.
-
- 09 11月, 2017 4 次提交
-
-
由 Ben Toews 提交于
-
由 Ben Toews 提交于
-
由 Ben Toews 提交于
-
由 Bogdan Gusiev 提交于
-
- 18 8月, 2017 1 次提交
-
-
由 Ryuta Kamizono 提交于
Otherwise random CI failure will be caused. https://travis-ci.org/rails/rails/jobs/265848046#L777
-
- 13 8月, 2017 1 次提交
-
-
由 Ryuta Kamizono 提交于
It is incorrect to treat `options[:primary_key]` as `association_primary_key` if `has_many` associations because the `:primary_key` means the column on the owner record, not on the association record. It will break `ids_reader` and `ids_writer`. ```ruby people(:david).essay_ids # => ActiveRecord::StatementInvalid: Mysql2::Error: Unknown column 'essays.first_name' in 'field list': SELECT `essays`.first_name FROM `essays` WHERE `essays`.`writer_id` = 'David' ``` Fixes #14439.
-
- 20 7月, 2017 1 次提交
-
-
由 Kir Shatrov 提交于
-
- 13 7月, 2017 1 次提交
-
-
由 Ryuta Kamizono 提交于
Since 07e5301e, `Relation#first` will order by primary key if no order is defined.
-
- 02 7月, 2017 1 次提交
-
-
由 Matthew Draper 提交于
This reverts commit 3420a145, reversing changes made to afb66a5a.
-
- 01 7月, 2017 1 次提交
-
-
由 Kir Shatrov 提交于
-
- 30 6月, 2017 1 次提交
-
-
由 Ryuta Kamizono 提交于
Fixes #29627.
-
- 29 6月, 2017 1 次提交
-
-
由 Ryuta Kamizono 提交于
Unscoping `default_scope` in associations has already supported (#17360 for preloading, c9cf8b8d for eager loading). Fixes #20679. Closes #16531.
-