| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
| | | | |
|
|\ \ \ \
| |/ / /
|/| | | |
Fix `counter_cache` double increment
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
When an `after_create` callback did `update_attributes` on a record with
multiple `belongs_to` associations with counter caches, even numbered
associations would have their counters double-incremented. Fixes to
`ActiveModel::Dirty` in 020abad fixed this.
This adds regression tests for this bug fixed incidentally in the other
commit, which also removed the need for the workaround using
@_after_create_counter_called.
|
|/ / / |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Since 5c71000, it has lost to be able to unscope `default_scope` in STI
associations. This change will use `.empty_scope?` instead of
`.values.empty?` to regard as an empty scope if only have
`type_condition`.
|
| | | |
|
|\ \ \
| | | |
| | | | |
Add a test case for overwriting existing condition on associations
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
Overwriting existing condition on associations has already supported
(23bcc65 for eager loading, 2bfa2c0 for preloading).
Fixes #27724.
Closes #29154.
|
|/ / /
| | |
| | |
| | |
| | | |
`FakeKlass` in `relation_test.rb` and `relation/mutation_test.rb` are
almost the same.
|
| | | |
|
| | |
| | |
| | |
| | |
| | | |
This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing
changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
|
| | | |
|
|\ \ \
| | | |
| | | | |
Remove unused `Subject` model in tests
|
| | | |
| | | |
| | | |
| | | | |
Because `subjects` table doesn't exist.
|
|\ \ \ \
| | | | |
| | | | | |
`Relation#locked?` should not build arel
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
The delegation was needed since passing `relation` with
`relation.bound_attributes`. It should use `relation.arel` in that case.
|
|/ / / /
| | | |
| | | |
| | | |
| | | |
| | | | |
Covering #27994 in tests.
Closes #27994.
|
|/ / /
| | |
| | |
| | |
| | | |
`belongs_to :developer` on `Comment` model was added in 431f8e0 but it
is unused.
|
| | | |
|
|\ \ \
| | | |
| | | | |
Extract `NumericData` model for tests
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
`attribute :world_population, :integer` is not a same with default
decimal without scale type unless #26302 is merged.
Should be `attribute :world_population, :big_integer` for now.
|
| | | |
| | | |
| | | |
| | | | |
Currently `NumericData` model is defined some places.
|
| | | | |
|
|\ \ \ \
| | | | |
| | | | |
| | | | | |
Fix association with extension issues
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
This fixes the following issues.
* `association_scope` doesn't include `default_scope`. Should use `scope` instead.
* We can't use `method_missing` for customizing existing method.
* We can't use `relation_delegate_class` for sharing extensions. Should extend per association.
|
|\ \ \ \ \
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
kamipo/refactor_enum_to_use_value_instead_of_label
Refactor enum to use `value` instead of `label` in the scope
|
| |/ / / / |
|
|\ \ \ \ \
| | | | | |
| | | | | | |
Delegate `ast` and `locked` to `arel` explicitly
|
| |/ / / /
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
Currently `ast` and `locked` are used in the internal but delegating to
`arel` is depend on `method_missing`. If a model class is defined these
methods, `select_all` will be broken.
It should be delegated to `arel` explicitly.
|
|/ / / / |
|
| | | |
| | | |
| | | |
| | | |
| | | | |
Since we have been using this `Arel::Table` since 111ccc832bc977b15af12c14e7ca078dad2d4373,
in order to properly handle queries, it's important that we properly type cast arguments.
|
| | | |
| | | |
| | | |
| | | |
| | | | |
Cannot call private methods in `@klass` against `CollectionProxy`
(inherites `Relation`) because using `public_send` in `method_missing`.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
`ClassSpecificRelation` has `method_missing` and the `method_missing` is
called first. if an associated class has the missing method in a
relation, never reach to the `method_missing` in the `CollectionProxy`.
I extracted `DelegateExtending` and included it to the delegate class
that including `ClassSpecificRelation` to fix the issue.
Fixes https://github.com/rails/rails/pull/28246#issuecomment-296033784.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
The issue #20802 has been fixed in cc0b566.
Closes #20802.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
Extension methods should not delegate to `scope` to respect dirty
target on `CollectionProxy`.
Fixes #28419.
|
| |/ /
|/| | |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
```
go get -u github.com/client9/misspell/cmd/misspell
misspell -w -error -source=text .
```
|
| | |
| | |
| | |
| | | |
Fixes #27666.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
The idea of `class_name` as an option of reflection is that passing a
string would allow us to lazy autoload the class.
Using `belongs_to :client, class_name: Customer` is eagerloading models more than necessary
and creating possible circular dependencies.
|
| | | |
|
| | |
| | |
| | |
| | | |
Actually, private methods cannot be called with `self.`, so it's not just redundant, it's a bad habit in Ruby
|
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
https://github.com/rails/rails/issues/26834
This change raises an error if a has_many through association
is defined before the through association.
|
|\ \ \
| | | |
| | | | |
Remove duplicated model class definitions in `test/cases/base_test.rb`
|
| | | | |
|
| | | | |
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
This issue was introduced with d849f42 to solve #19782. However, we can
solve #19782 without causing the issue. It is enough to save only when
necessary.
Fixes #27338.
|
| | | | |
|
|/ / / |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
callbacks
We pretty frequently get bug reports that "dirty is broken inside of
after callbacks". Intuitively they are correct. You'd expect
`Model.after_save { puts changed? }; model.save` to do the same thing as
`model.save; puts model.changed?`, but it does not.
However, changing this goes much farther than just making the behavior
more intuitive. There are a _ton_ of places inside of AR that can be
drastically simplified with this change. Specifically, autosave
associations, timestamps, touch, counter cache, and just about anything
else in AR that works with callbacks have code to try to avoid "double
save" bugs which we will be able to flat out remove with this change.
We introduce two new sets of methods, both with names that are meant to
be more explicit than dirty. The first set maintains the old behavior,
and their names are meant to center that they are about changes that
occurred during the save that just happened. They are equivalent to
`previous_changes` when called outside of after callbacks, or once the
deprecation cycle moves.
The second set is the new behavior. Their names imply that they are
talking about changes from the database representation. The fact that
this is what we really care about became clear when looking at
`BelongsTo.touch_record` when tests were failing. I'm unsure that this
set of methods should be in the public API. Outside of after callbacks,
they are equivalent to the existing methods on dirty.
Dirty itself is not deprecated, nor are the methods inside of it. They
will only emit the warning when called inside of after callbacks. The
scope of this breakage is pretty large, but the migration path is
simple. Given how much this can improve our codebase, and considering
that it makes our API more intuitive, I think it's worth doing.
|
| | | |
|