| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
| |
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
|
| | |
|
| | |
|
| | |
|
|/
|
|
|
| |
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
|
|
|
|
|
|
|
|
|
|
| |
- we are ending sentences properly
- fixing of space issues
- fixed continuity issues in some sentences.
Reverts https://github.com/rails/rails/commit/8fc97d198ef31c1d7a4b9b849b96fc08a667fb02 .
This change reverts making sure we add '.' at end of deprecation sentences.
This is to keep sentences within Rails itself consistent and with a '.' at the end.
|
|
|
|
|
| |
Introduce a predicate method that doesn't need to build a scope chain,
but also hides the data structure used for representing the scope chain.
|
|
|
|
|
|
|
|
| |
We know a reflection can be considered as `nested?` if the source
reflection or the through reflection are also through reflections (since
the through reflection will also add another join table). This allows
us to avoid traversing the entire reflection tree just to calculate whether or
not there will be more join tables.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
When the `source_type` option is passed to a has_many through, the
resulting `Reflection` will be an instance of `PolymorphicReflection`
and not `ThroughReflection`, meaning that it will ignore the scopes that
it needs to apply from the through reflections. This adds an additional
delegation call to remedy this. I've been finding the reflection code
completely impenetrable lately, it could use some major love.
Fixes #22726
|
|
|
|
|
|
|
| |
This commit walks the reflection tree and builds the scope chain
functionally. It also removes the chain cache since the cache doesn't
seem to have any impact on performance (I'd prefer to only cache at
proven bottlenecks)
|
|\ |
|
| | |
|
| |
| |
| |
| |
| |
| |
| | |
ActiveRecord's Reflection was refactored by
f8d2899d12d59360f29c5eb6a1b1a8fe4ec82ca0 .
Top of ancestors chain was changed to `AbstractReflection` from
`MacroReflection`, and new Reflections were added.
|
| |
| |
| |
| |
| |
| | |
`#initialize` of `HasManyReflection`, `HasOneReflection` and
`BelongsToReflection` only pass all arguments to `super` by passed order.
These overriding can be removed.
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Rails has abstract Reflection classes (`MacroReflection`,
`AssociationReflection` etc.) and concrete Reflection classes
(e.g. `HasManyReflection`, `HasOneReflection` etc.).
In many case `calculate_constructable` returns `true`, so
change `calculate_constructable` to always return `true` and
override this method if necessary.
|
| | |
|
|\ \
| |/
|/|
| |
| |
| |
| |
| |
| |
| |
| | |
* 5-0-beta-sec:
bumping version
fix version update task to deal with .beta1.1
Eliminate instance level writers for class accessors
allow :file to be outside rails root, but anything else must be inside the rails view directory
Don't short-circuit reject_if proc
stop caching mime types globally
use secure string comparisons for basic auth username / password
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Instance level writers can have an impact on how the Active Model /
Record objects are saved. Specifically, they can be used to bypass
validations. This is a problem if mass assignment protection is
disabled and specific attributes are passed to the constructor.
CVE-2016-0753
|
|/ |
|
|
|
|
|
|
|
|
|
|
|
|
| |
The string returned here will ultimately get used as a key of a hash in
the attribute set once the attributes are being built. When you give a
non-frozen string to `Hash#[]`, it will be duped. Be freezing we can
significantly reduce the number of times we end up allocating
`"user_id"`
This does not include any additional tests, as this should not have any
public facing implications. If you are mutating the result of
`Reflection#foreign_key`, please stop.
|