| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
| |
Fixes #31762.
|
|
|
|
|
|
| |
When removing a record from a has many through association, the counter
cache was being updated even if the through record halted the callback
chain and prevented itself from being destroyed.
|
|\
| |
| |
| | |
When deleting through records, take into account association conditions
|
| |
| |
| |
| |
| |
| |
| |
| | |
Fixes #18424.
When deleting through records, it didn't take into account the
conditions that may have been affecting join model table, but was
defined in association definition.
|
| |
| |
| |
| | |
Need reloading when through record has replaced.
|
|\ \
| | |
| | |
| | |
| | |
| | | |
zoltankiss/allow-nested-has-many-associations-on-unpersisted-parent-instances
fix nested `has many :through` associations on unpersisted parent instances
|
| | |
| | |
| | |
| | | |
Fixes: #16313
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Currently reflections keeps the order when first added even if when
redefining association. As a result of the order, redefining through
association which use newly added association will raise
`HasManyThroughOrderError`. We need to redefine reflection order as well
when redefining association.
Fixes #31068.
|
|\ \ \
| | | |
| | | |
| | | | |
Use `count(:all)` in HasManyAssociation#count_records
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
Problem: Calling `count` on an association can cause invalid SQL queries
to be created where the `SELECT COUNT(a, b, c)` function receives
multiple columns. This will cause a `StatementInvalid` exception later
on.
Solution: Use `count(:all)`, which generates a `SELECT COUNT(*)...`
query independently of the association.
This also includes a test case that, before the fix, broke.
|
| | | |
| | | |
| | | |
| | | | |
This is a regression test for #27864.
|
| | | |
| | | |
| | | |
| | | | |
when model is added to collection association
|
| | | |
| | | |
| | | |
| | | | |
Follow up of #31432.
|
| | | |
| | | |
| | | |
| | | | |
Follow up of #31390.
|
|\ \ \ \
| | | | |
| | | | |
| | | | |
| | | | | |
chopraanmol1/bug_fix_has_one_inverse_owner_reload_from_validation
Inverse instance should not be reloaded during autosave if called in validation
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
Record saved in save_has_one_association already make call to association.loaded! via record's before_save callback of save_belongs_to_association,
but this will reload object if accessed in record's validation.
|
|/ / / / |
|
|\ \ \ \
| | | | |
| | | | |
| | | | | |
Disallow raw SQL in dangerous AR methods
|
| | | | | |
|
| | | | | |
|
| | | | | |
|
|/ / / / |
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
This is partially fixed by e617fb57 when through association has already
loaded. Otherwise, second level through association should respect
`preload_scope`.
Fixes #30242.
Closes #30076.
[Ryuta Kamizono & CicholGricenchos]
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
loaded
If through association has already loaded, `source_type` is ignored to
loaded through records. The loaded records should be filtered by
`source_type` in that case.
Fixes #30904.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
`join_scopes` in `PolymorphicReflection` is passed aliased `table`, so
it should be respected for `source_type_scope`.
Closes #13969.
Fixes #13920.
Fixes #15190.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
```
% git grep -n trough
activerecord/test/cases/associations/has_many_through_associations_test.rb:1253: def test_has_many_trough_with_scope_that_has_joined_same_table_with_parent_relation
```
|
| | | | |
|
|\ \ \ \
| | | | |
| | | | | |
delegate scope_for on PolymorphicReflection
|
| | | | | |
|
|/ / / / |
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
Currently alias tracker only refer a table name, doesn't respect an
alias name. Should use `join.left.name` rather than
`join.left.table_name`.
|
| | | | |
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
It should be shared the count of alias tracking in both INNER/LEFT JOINs
to avoid duplicate aliases.
Fixes #30504.
Closes #30410.
|
| | | |
| | | |
| | | |
| | | |
| | | | |
Currently we have no test for alias tracking with string joins. I've add
test case for that to catch a future regression.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
`exists?`
This test covers the case of 02da8aea.
Previously `exists?` was always eager-loading the includes values. But
now it is eager-loaded only when necessary since 07a611e0.
So the case of the eager-loading had not covered in the test.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
For investigating the cause of failure.
https://travis-ci.org/rails/rails/jobs/287474883#L797-L799
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
parent relation's aliases
Building association scope in join dependency should respect the parent
relation's aliases to avoid using the same alias name more than once.
Fixes #30681.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
The order of scope evaluation should be from through scope to the
association's own scope. Otherwise the association's scope cannot affect
to through scope.
Fixes #13677.
Closes #28449.
|
| | | |
| | | |
| | | |
| | | | |
Because this is not a test case.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
If `reflection_scope.where_clause` is not empty, `through_scope` should
be joined the source association. But if `values[:references]` in
`reflection_scope` is empty, the source association will not be joined.
It should use `source_reflection.table_name` in that case.
Fixes #22535.
Closes #28763.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
If `reflection_scope.where_clause` is not empty, `through_scope` should
be joined the source association. But if the through association doesn't
have explicit `:source`, `options[:source]` will be nil and
`scope.includes_values` will also be empty. It should use
`source_reflection.name` rather than `options[:source]`.
Fixed by a26cff3c1235c61cd0135bed4ef63d7be452b458.
Fixes #11078.
Fixes #26129.
Closes #14312.
Closes #29155.
Closes #29841.
|
| | | | |
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
This regression was caused by caa178c1. The block for
`set_inverse_instance` should also be passed to join dependency.
Fixes #30402.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
`:authors` has a foreign key to `:author_addresses`.
If only `:authors` fixture loaded into the database which supports
foreign key and checks the existing data when enabling foreien keys
like Oracle, it raises the following error
`ORA-02298: cannot validate (ARUNIT.FK_RAILS_94423A17A3) - parent keys not found`
It is because there is no parent data exists in `author_addresses` table.
Here are how other database with foreign key support works:
- MySQL does not check the existing data when enabling foreign key by `foreign_key_checks=1`
https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_foreign_key_checks
> Setting foreign_key_checks to 1 does not trigger a scan of the existing table data. Therefore, rows added to the table while foreign_key_checks=0 will not be verified for consistency.
- PostgreSQL database itself has a feature to check existing data when
enabling foreign key and discussed at #27636, which is reverted.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
ActiveRecord associations automatically guess the inverse associations.
But this feature does not work correctly on assoctions for STI.
For example, before this commit
```
class Post < ActiveRecord::Base
belongs_to :author
end
class SpecialPost < Post; end
class Author < ActiveRecord::Base
has_many :posts
has_many :special_posts
end
```
`author.posts.first.author` works correctly, but
`author.special_posts.first.author` does not work correctly.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
Otherwise random CI failure will be caused.
https://travis-ci.org/rails/rails/jobs/265848046#L777
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
Follow up of #29834.
Fixes #30266.
|
|\ \ \ \
| | | | |
| | | | |
| | | | | |
Ensure sum honors distinct on has_many through
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
When using a has_many through relation and then summing an attribute
the distinct was not being used. This will ensure that when summing
an attribute, the number is only used once when distinct has been used.
|
|\ \ \ \ \
| | | | | |
| | | | | | |
Clarify base_class tests on abstract STI vs concrete STI
|