| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|\ \ \ \
| | | | |
| | | | | |
Don't rely on the column for type casting reflections
|
| |/ / / |
|
|\ \ \ \
| | | | |
| | | | |
| | | | | |
Don't include inheritance column in the through_scope_attributes
|
| |/ / / |
|
|/ / /
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
namespaced model
Now the following case will work fine
class Tag < ActiveRecord::Base
end
class Publisher::Article < ActiveRecord::Base
has_and_belongs_to_many :tags
end
Fixes #15761
|
|\ \ \
| | | |
| | | | |
Open extension point for defining options in build_through_record
|
| | | |
| | | |
| | | |
| | | | |
This fixes #15496
|
|/ / /
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
member = Member.new(club: Club.new)
member.save!
Before:
member.current_membership.club_id # => nil
After:
member.current_membership.club_id # => club's id
|
| |/
|/|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
add_constraints is complicated and difficult to read. This is the
beginning of a long process of refactoring this code. First step:
moved the join keys out of AssociationScope and into reflection.
We then don't need to call `reflection` because now reflection is
`self`.
`foreign_key` must be named something else because reflection already has a
`foreign_key` method and when passed into `JoinKeys` it was getting the
wrong assignment. `reflection_foreign_key` seemed to be an appropriate name.
I also named `key` `reflection_key` to match `reflection_foreign_key`.
|
| |
| |
| |
| |
| |
| |
| | |
Reflection has an available method that is used to check if the
reflection is a collection. Any :has_many macro is considered a
collection and `collection?` should be used instead of
`macro == :has_many`.
|
| |
| |
| |
| |
| |
| | |
Instead of checking for `macro == :has_one` throughout the
codebase we can create a `has_one?` method to match the `belongs_to?`,
`polymorphic?` and other methods.
|
| |
| |
| |
| |
| |
| |
| |
| | |
In some cases there is a difference between the two, we should always
be doing one or the other. For convenience, `type_cast` is still a
private method on type, so new types that do not need different behavior
don't need to implement two methods, but it has been moved to private so
it cannot be used accidentally.
|
| |
| |
| |
| |
| |
| |
| | |
Integration tests are inside protected_attributes test suite.
Fixes #15496
Fixes rails/protected_attributes#35
|
| | |
|
| | |
|
|\ \
| | |
| | |
| | |
| | |
| | |
| | | |
Fix regression on eager loading association based on SQL query rather than existing column.
Conflicts:
activerecord/CHANGELOG.md
|
| | |
| | |
| | |
| | |
| | |
| | | |
than existing column.
Fixes #15480.
|
|/ /
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Reflection has a `belongs_to?` method. Instead of checking for
`macro == :belongs_to` throughout the source reuse existing
method.
I also bumped `foreign_key_present?` method onto on line because
the `belongs_to?` makes it shorter than other longer lines in
the same class.
|
| |
| |
| |
| |
| |
| | |
Fix polymorphic to check for `options[:polymorphic]` instead of
`options.key? :polymorphic` and then reuse the method `polymorphic?`
method instead of constantly checking the same `options[:polymorphic]`.
|
|\ \
| | |
| | | |
Correctly alias table names when joining more than once
|
| | | |
|
|\ \ \
| | | |
| | | |
| | | | |
Skip if the association was already loaded.
|
| | | | |
|
|/ / /
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Fix habtm reflection
Conflicts:
activerecord/CHANGELOG.md
activerecord/lib/active_record/counter_cache.rb
activerecord/lib/active_record/reflection.rb
activerecord/test/cases/reflection_test.rb
|
|\ \ \
| | | |
| | | |
| | | | |
Fix polymorphic eager load with foreign_key as String.
|
|/ / /
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
The foreign_key could be `String` and just doing `owners_map[owner_key]`
could return `nil`.
To prevent this bug, we should `to_s` both keys if their types are
different.
Fixes #14734.
|
| | | |
|
| | | |
|
| | |
| | |
| | |
| | | |
Fixes #14824.
|
|/ /
| |
| |
| |
| |
| | |
When delete or destroy is called on all records nothing
is deleted or destroyed. Intead of running through the code and still
not deleteing anything, we should early return
|
| |
| |
| |
| |
| |
| | |
cc:
https://github.com/rails/rails/commit/a11e2fcff8cdc9691b977d8330abe63024f8c732#commitcomment-6353614
and 0369dbf
|
| | |
|
| |
| |
| |
| |
| | |
parent_name is a string of nil, never a blank string so we don't need to
use presence.
|
|\ \
| | |
| | |
| | |
| | |
| | |
| | | |
Fix how to compute class name on habtm namespaced.
Conflicts:
activerecord/CHANGELOG.md
|
| | |
| | |
| | |
| | |
| | |
| | | |
Thank's for @laurocaetano for the help with tests. :smiley:
Fixes #14709
|
| | |
| | |
| | |
| | | |
this change was unneccsary as nothing was gained from it
|
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Rename delete_all_records because this name better describes
what the method is doing. We can then remove :all from the
hm:t version and pull out the unoptimized call to load_target
in delete_records and pass it directly.
|
| | |
| | |
| | |
| | |
| | |
| | | |
Refactor delete_count method to only handle delete_all or nullify/nil cases
and not destroy and switch to if/else rather than case statement. This
refactoring allows removal of :all symbol usage.
|
|/ /
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Refactor by creating two methods delete_all_records and delete_records
to be called by delete_all and delete (or destroy) respectively.
This reduces the number of conditionals required to handle _how_
records get deleted.
The new delete_count method handles how scope is applied to which
delete action.
A delete_all_records method also has to be called in has_many_through
association because of how the methods are chained. This will be
refactored later on.
|
| |
| |
| |
| |
| |
| |
| | |
Closes #15024.
These operations happen before instances are created.
The current behavior is misleading and can result in broken behavior.
|
| |
| |
| |
| |
| | |
HABTM should fall back to using the normal CollectionAssociation's size calculation if the collection is not cached or loaded.
This addresses both #14913 and #14914 for master.
|
| |
| |
| |
| |
| |
| |
| |
| | |
Rewrite to avoid 'we'/'you', add missing period, and keep lines at 80 chars. Cheers :)
Improve readability with help from @senny
[ci skip]
|
|\ \
| | |
| | | |
Refactored AssociationScope#get_bind_values
|
| | |
| | |
| | |
| | | |
Added #join_id_for(owner) to reflection to avoid accessing the source_macro
|
| | | |
|
|/ /
| |
| |
| |
| |
| |
| |
| | |
Now that delete_all with destroy or delete_all dependency behave
the same we no longer need this conditional. This means we can remove
the new delete_all_with_dependency method I added and go straight
to delete_records from delete_all, passing :all and the dependent
directly.
|
| |
| |
| |
| |
| |
| |
| |
| | |
Nullify (or nil dependency) was doing the same thing delete_all
was doing in issue #14546, creating a large IN statement if
the association was loaded. Loaded and not loaded associations
should behave the same. The IN statement is also not great because
it's inefficient.
|
| |
| |
| |
| |
| |
| |
| | |
After reviewing this code I realized the conditional that was
there previously was basically saying if the dependency is not
delete all. This is a better, cleaner, and clearer way to write
this method.
|
| |
| |
| |
| |
| | |
Now that we have a new method delete_all_with_dependency this
coupled conditional is no longer needed.
|
| |
| |
| |
| |
| |
| | |
The delete method is very coupled with delete all even
though only a portion of the conditionals apply. Decoupling
this will make the code easier to understand and manipulate.
|