| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
| | | |
|
|\ \ \
| |/ /
|/| | |
Fix automatic inverse for polymorphic interfaces
|
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
This makes automatic inverse detection possible for polymorphic
:has_one & :has_many possible.
This resolves a number of issues, eg. `touch: true` on polymorphic relationships (#16446) and automatically setting inverse associations on newly built objects (#15028, #21843).
|
|\ \ \
| | | |
| | | | |
Remove `HasAndBelongsToManyReflection#initialize`
|
| |/ /
| | |
| | |
| | | |
It is delegating `super` only.
|
| | | |
|
| | | |
|
| | | |
|
| | | |
|
| | | |
|
| | | |
|
|\ \ \
| | | |
| | | |
| | | | |
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.
|
|/ / /
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
* Allow a default value to be declared for class_attribute
* Convert to using class_attribute default rather than explicit setter
* Removed instance_accessor option by mistake
* False is a valid default value
* Documentation
|
| | |
| | |
| | |
| | | |
Follow up of #25702.
|
| | |
| | |
| | |
| | |
| | | |
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.
|
|/ / |
|
| |
| |
| |
| |
| |
| | |
Reflections only use their own information to create a `join_keys`
object. This means that we can call `join_keys` on a reflection object
and have it be context-free.
|
| | |
|
| | |
|
| |
| |
| |
| |
| |
| |
| | |
Scopes can only ever be *not* reflection objects when they are passed in
to the Reflection constructor. Given this fact, we can eliminate is_a
checks and an intermediate array object by just asking the reflection
object for join scopes.
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
When the association's primary key is manually set as a symbol and called with an array of strings, CollectionAssociation#ids_writer
fails to cast the ids to integers. This is because
AssociationReflection#association_primary_key_type and
ThroughReflection#association_primary_key_type return the incorrect
type, since ModelSchema.type_for_attribute only accepts a string. The
result is an ActiveRecord::RecordNotFound error.
|
| |
| |
| |
| |
| |
| |
| | |
Lambda scopes require a bunch more work. Ideally the `scope` list would
be a homogeneous collection. In this case, the reflection knows how to
construct the right reflection for this join, so lets just construct
that relation rather than instance execing to figure it out later.
|
| | |
|
| | |
|
| | |
|
| |
| |
| |
| | |
`PolymorphicReflection` needs to be custom for handling scope lambdas
|
| |
| |
| |
| |
| | |
Each reflection should be responsible for returning the scopes needed to
query against the db.
|
|\ \
| | |
| | |
| | |
| | | |
Conflicts:
railties/lib/rails/generators.rb
|
| | |
| | |
| | |
| | |
| | |
| | | |
Removes space from the word; is now spelled in the standard way.
[ci skip]
|
| | | |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
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.
|
| | | |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
https://github.com/rails/rails/issues/26834
This change raises an error if a has_many through association
is defined before the through association.
|
|/ / |
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| | |
Fixes casting of IDs to the data type of the association primary key,
rather than then the data type of the model's primary key. (Tests use a
string primary key on the association, rather than an int.)
Tests issue #20995
|
|\ \
| | |
| | | |
Add missing `+` around a some literals.
|
| | |
| | |
| | |
| | |
| | |
| | | |
Mainly around `nil`
[ci skip]
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
With the changes in #25337, double save bugs are pretty much impossible,
so we can just lift this restriction with pretty much no change. There
were a handful of cases where we were relying on specific quirks in
tests that had to be updated. The change to has_one associations was due
to a particularly interesting test where an autosaved has_one
association was replaced with a new child, where the child failed to
save but the test wanted to check that the parent id persisted to `nil`.
I think this is almost certainly the wrong behavior, and I may change
that behavior later. But ultimately the root cause was because we never
remove the parent in memory when nullifying the child. This makes #23197
no longer needed, but it is what we'll do to fix some issues on 5.0
Close #23197
|
| | | |
|
|\ \ \
| |/ /
|/| |
| | |
| | | |
kamipo/polymorphic_reflection_is_not_using_methods_from_through_reflection
`PolymorphicReflection` is not using the methods from `ThroughReflection`
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
`ThroughReflection` initializes `@delegate_reflection` and delegate all
public methods to `delegate_reflection`. But `PolymorphicReflection`
does not initialize `@delegate_reflection`.
It is enough to inherit `AbstractReflection` (using `alias_candidate`
only).
|
| | | |
|
| | | |
|
|\ \ \
| | | |
| | | |
| | | | |
Preserve readonly flag only for readonly association
|
| |/ /
| | |
| | |
| | | |
Fixes #24093
|
| | | |
|
| | | |
|
| | | |
|