| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
| |
| |
| |
| |
| |
| | |
By concatnating the `ReflectionProxy` with the `chain` we remove
the need for `#construct_tables` because the `chain` is now in the
correct order (order of the chain DOES matter).
|
| |
| |
| |
| |
| | |
Putting the `#alias_name` into ReflectionProxy means we don't have to
cache the `#alias_name` globally anymore - it's not cached per query.
|
| |
| |
| |
| |
| |
| | |
`is_first_chain`, `items` and `klass` are no longer beneficial and can
be called directly instead of via their assignments - because they are
each only used once.
|
| |
| |
| |
| |
| | |
Move method structure into reflection classes for accessibly on each
reflection rather than by traversing the chain.
|
| |
| |
| |
| |
| |
| |
| | |
The `RuntimeReflection` class allows the reflection to be accessed at
runtime - then we always know which reflection we are accessing in the
chain. The `#get_chain` method then allows us to recursively access the
chain through the `RuntimeReflection`.
|
| |
| |
| |
| |
| |
| | |
`#constraints` builds a flattened version of `scope_chain` to
allow it to be accessible without requiring an index when iterating
over the `scope_chain`
|
|\ \
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Add setting of FK for throgh associations while building
Conflicts:
activerecord/CHANGELOG.md
activerecord/test/cases/associations/has_many_through_associations_test.rb
|
| | | |
|
| | | |
|
| | | |
|
| | |
| | |
| | |
| | | |
Fixes #18237
|
| | | |
|
| | | |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
This will allow eager type casting to take place as needed. There
doesn't seem to be any particular reason that the `in` statement was
forced for single values, and the commit message where it was introduced
gives no context.
See
https://github.com/rails/rails/commit/d90b4e2615e8048fdeffc6dffe3246704adee01f
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
This class cares far too much about the internals of other parts of
Active Record. This is an attempt to break out a meaningful object which
represents the needs of the predicate builder. I'm not fully satisfied
with the name, but the general concept is an object which represents a
table, the associations to/from that table, and the types associated
with it. Many of these exist at the `ActiveRecord::Base` class level,
not as properties of the table itself, hence the need for another
object. Currently it provides these by holding a reference to the class,
but that will likely change in the future. This allows the predicate
builder to remain wholy concerned with building predicates.
/cc @mrgilman
|
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Construction of relations can be a hotspot, we don't want to create one
of these in the constructor. This also allows us to do more expensive
things in the predicate builder's constructor, since it's created once
per AR::Base subclass
|
| | |
| | |
| | |
| | | |
reference to past scope`
|
| | |
| | |
| | |
| | |
| | | |
All cases are properly handled in CollectionAssociation
for all subclasses of this association
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
`ActiveRecord::Base#[]` has overhead that was introduced in 4.2. The
`foo["id"]` working with PKs other than ID isn't really a case that we
want to support publicly, but deprecating was painful enough that we
avoid it. `_read_attribute` was introduced as the faster alternative for
use internally. By using that, we can save a lot of overhead. We also
save some overhead by reading the attribute one fewer times in
`stale_state`.
Fixes #18151
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Because we're only using the `connection` so passing the entire tracker
isn't unnecessary.
Eventually only the `connection` will be passed to `add_constraints`
with later refactoring but curretly that's not possible because of
`construct_tables` method.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
To be possible to use a custom column name to save/read the polymorphic
associated type in a has_many or has_one polymorphic association, now users
can use the option :foreign_type to inform in what column the associated object
type will be saved.
|
| | |
| | |
| | |
| | |
| | | |
`where_sql` now requires that we pass it an engine. None of the manager
classes take an engine in their constructor.
|
| | | |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
This fixes a regression where preloading association throws an
exception if one of the associations in the preloading hash doesn't
exist for one record.
Fixes #16070
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
The records weren't being replaced since equality in Active Record is
defined in terms of `id` only. It is reasonable to expect that the
references would be replaced in memory, even if no queries are actually
executed. This change did not appear to affect any other parts of the
code base. I chose not to execute callbacks since we're not actually
modifying the association in a way that will be persisted.
Fixes #17730
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
This refactoring reduces the number of conditionals needed to build
`aliased_table_for` and removes `aliased_name_for` because it's no
longer necessary.
`aliased_name_for` was also used in `JoinDependency#initialize` so
that was replaced with `aliased_table_for` as well.
|
| | |
| | |
| | |
| | | |
on the joined assoiciation
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
I grepped the source code for code snippets wrapped in backticks in the comments
and replaced the backticks with plus signs so they are correctly displayed in
the Rails documentation.
[ci skip]
|
|\ \ \
| | | |
| | | | |
Allow class_name option in habtm to be consistent with other association...
|
| | | | |
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
We added a comparison to "id", and call to `self.class.primary_key` a
*lot*. We also have performance hits from `&block` all over the place.
We skip the check in a new method, in order to avoid breaking the
behavior of `read_attribute`
|
| | | |
| | | |
| | | |
| | | | |
Oh hey, we got to remove some code because of that!
|
|\ \ \ \
| |/ / /
|/| | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
Empact/association-bind-values-not-updated-on-save
Fix that a collection proxy could be cached before the save of the owner, resulting in an invalid proxy lacking the owner’s id
Conflicts:
activerecord/CHANGELOG.md
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
resulting in an invalid proxy lacking the owner’s id.
Absent this fix calls like: owner.association.update_all to behave unexpectedly because they try to act on association objects where
owner_id is null.
more evidence here: https://gist.github.com/Empact/5865555
```
Active Record 3.2.13
-- create_table(:firms, {:force=>true})
-> 0.1371s
-- create_table(:clients, {:force=>true})
-> 0.0005s
1 clients. 1 expected.
1 clients updated. 1 expected.
```
```
Active Record 4.0.0
-- create_table(:firms, {:force=>true})
-> 0.1606s
-- create_table(:clients, {:force=>true})
-> 0.0004s
1 clients. 1 expected.
0 clients updated. 1 expected.
```
|
| | | | |
|
| | | |
| | | |
| | | |
| | | | |
fixes #17495
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
if you specify a default scope on a model, it will break caching. We
cannot predict what will happen inside the scope, so play it safe for
now. fixes #17495
|
|\ \ \ \
| | | | |
| | | | |
| | | | | |
copy reflection_scopes’s unscoped value when building scope for preloading
|
| | | | |
| | | | |
| | | | |
| | | | | |
preloading, fixes #11036
|
| | | | | |
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
In practical terms, this allows serialized columns and tz aware columns
to be used in wheres that go through joins, where they previously would
not behave correctly. Internally, this removes 1/3 of the cases where we
rely on Arel to perform type casting for us.
There were two non-obvious changes required for this. `update_all` on
relation was merging its bind values with arel's in the wrong order.
Additionally, through associations were assuming there would be no bind
parameters in the preloader (presumably because the where would always
be part of a join)
[Melanie Gilman & Sean Griffin]
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
This patch uniformizes warning messages. I used the most common style
already present in the code base:
* Capitalize the first word.
* End the message with a full stop.
* "Rails 5" instead of "Rails 5.0".
* Backticks for method names and inline code.
Also, converted a few long strings into the new heredoc convention.
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
The current style for warning messages without newlines uses
concatenation of string literals with manual trailing spaces
where needed.
Heredocs have better readability, and with `squish` we can still
produce a single line.
This is a similar use case to the one that motivated defining
`strip_heredoc`, heredocs are super clean.
|
|/ / / /
| | | |
| | | |
| | | | |
This will avoid naming clash with user defined methods
|
| | | |
| | | |
| | | |
| | | | |
follow up for #17052
|
| | | |
| | | |
| | | |
| | | |
| | | | |
For now, we don't want to take "scoping" calls in to account when
calculating cache keys for relations, so just opt-out.
|
| | | |
| | | |
| | | |
| | | |
| | | | |
emit an event when we instantiate AR objects so we can see how many
records were instantiated and how long it took
|
|\ \ \ \
| | | | |
| | | | | |
Change `gsub` to `tr` where possible
|
| |/ / / |
|
|/ / /
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
For detailed testing of behavior see:
https://gist.github.com/eileencodes/5b0a2fe011dcff6203fe
This shows destroy_all always destroys records and fires callbacks.
It will never use nullify or delete_all
delete_all's behavior varies greatly based on `hm` vs `hm:t` and deletion
strategy.
|