| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
| |
polymorphic association [#17263]
|
|
|
|
|
| |
emit an event when we instantiate AR objects so we can see how many
records were instantiated and how long it took
|
|
|
|
| |
to drop sequences at the same time each tables dropped for Oracle
|
|
|
|
|
|
|
|
|
|
|
| |
Callback order in Active Record objects are important. Users should not
define callbacks before the association definition or surprising
behaviours like the described at #3798 will happen. This callback order
dependency is documented at https://github.com/rails/rails/blob/31bfcdc77ca0d8cec9b5fe513bdc6f05814dd4f1/activerecord/lib/active_record/associations.rb#L1222-1227.
This reverts #15728.
Fixes #16620.
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is cased by 03118bc + 9b5d603. The first commit referenced the undefined
local variable `column` when it should be using `reflection.type` as the lookup
key. The second commit changed `build_arel` to not modify the `bind_values` in-
place so we need to combine the arel's `bind_values` with the relation's when
building the SQL.
Fixes #16591
Related #15821 / #15892 / 7aeca50
|
|
|
|
|
| |
Since 'drop table if exists' statement does not always work with
some databases such as Oracle.
|
| |
|
| |
|
| |
|
|\
| |
| | |
If a counter_cache exists, use it for #empty?
|
| | |
|
| | |
|
| | |
|
| |
| |
| |
| | |
This reverts commit e84799d, e31104c and e6ca8e2
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
In addition to defining the association, a `required` association will
also have its presence validated.
Before:
```ruby
belongs_to :account
validates_presence_of :account
```
After:
```ruby
belongs_to :account, required: true
```
This helps to draw a distinction between types of validations, since
validations on associations are generally for data integrity purposes,
and aren't usually set through form inputs.
|
| | |
|
| | |
|
| | |
|
|\ \
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Fix bug, when ':dependent => :destroy' violates foreign key constraints
Conflicts:
activerecord/CHANGELOG.md
activerecord/lib/active_record/associations/builder/association.rb
activerecord/lib/active_record/associations/builder/has_one.rb
|
| | |
| | |
| | |
| | | |
constraints, issue #12380
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Reliant on https://github.com/rails/rails/pull/15747 but pulled to a
separate PR to reduce noise. `has_many :through` associations have the
undocumented behavior of automatically detecting counter caches.
However, the way in which it does so is inconsistent with counter caches
everywhere else, and doesn't actually work consistently.
As with normal `has_many` associations, the user should specify the
counter cache on the `belongs_to`, if they'd like it updated.
|
| | |
| | |
| | |
| | |
| | |
| | | |
This is a partial fix for #15853. It only works when a `preload`
is issued and not an `eager_load`. I've added a skipped failing
test-case to keep in mind that we need to deal with `eager_load`.
|
|\ \ \
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
Don't save through records twice
Conflicts:
activerecord/CHANGELOG.md
activerecord/test/cases/associations/has_many_through_associations_test.rb
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
If the through record gets created in an `after_create` hook that is
defined before the association is defined (therefore after its
`after_create` hook) get saved twice. This ensures that the through
records are created only once, regardless of the order of the hooks.
|
|\ \ \ \
| | | | |
| | | | | |
Always update counter caches in memory when adding records
|
| |/ / /
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
Before, calling `size` would only work if it skipped the cache, and
would return a different result from the cache, but only if:
- The association was previously loaded
- Or you called size previously
- But only if the size was 0 when you called it
This ensures that the counter is appropriately updated in memory.
|
|\ \ \ \
| | | | |
| | | | |
| | | | | |
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
|
|\ \ \
| | | |
| | | | |
prevent bad automatic inverse_of association
|
| | | |
| | | |
| | | |
| | | | |
reflecting on wrong association
|
| |_|/
|/| |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
member = Member.new(club: Club.new)
member.save!
Before:
member.current_membership.club_id # => nil
After:
member.current_membership.club_id # => club's id
|
| | |
| | |
| | |
| | |
| | |
| | | |
`InverseHasManyTests#test_parent_instance_should_be_shared_within_create_block_of_new_child`
was mistakenly the same as
`InverseHasManyTests#test_parent_instance_should_be_shared_within_build_block_of_new_child`.
|
| | |
| | |
| | |
| | |
| | |
| | | |
than existing column.
Fixes #15480.
|
| | | |
|
|\ \ \
| | | |
| | | | |
Correctly alias table names when joining more than once
|
| | | | |
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
After ad7b5efb55bcc2e0ccd3e7f22a81e984df8676d1, which changed how
has_an_belongs_to_many used to work, we start raising an error when
redefining the same has_an_belongs_to_many association. This commits fix
that regression.
[Fixes #14983]
|
| | | | |
|
| | | |
| | | |
| | | |
| | | | |
All preload tests are in the eager_test file
|
| |/ /
|/| | |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
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.
|
| | | |
|
|/ / |
|
| |
| |
| |
| |
| |
| | |
Thank's for @laurocaetano for the help with tests. :smiley:
Fixes #14709
|
| |
| |
| |
| |
| |
| |
| | |
Closes #15024.
These operations happen before instances are created.
The current behavior is misleading and can result in broken behavior.
|
| | |
|
| |
| |
| |
| |
| | |
I wanted the middle model to be anonymous, but we have to give it a name
for marshal support. :'(
|
| |
| |
| |
| |
| | |
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.
|