| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
| |
| |
| |
| |
| | |
Dangerous association names conflicts include instance or class
methods already defined by `ActiveRecord::Base`.
|
| | |
|
| |
| |
| |
| | |
Need to define #reset on CollectionProxy.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This commit fixes two regressions introduced in cafe31a078 where
newly created finder methods #second, #third, #forth, and #fifth
caused a NoMethodError error on reload associations and where we
were pulling the wrong element out of cached associations.
Examples:
some_book.authors.reload.second
# Before
# => NoMethodError: undefined method 'first' for nil:NilClass
# After
# => #<Author id: 2, name: "Sally Second", ...>
some_book.first.authors.first
some_book.first.authors.second
# Before
# => #<Author id: 1, name: "Freddy First", ...>
# => #<Author id: 1, name: "Freddy First", ...>
# After
# => #<Author id: 1, name: "Freddy First", ...>
# => #<Author id: 2, name: "Sally Second", ...>
Fixes #13783.
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Since Rails 4.0, we add an ORDER BY in the `first` method to ensure consistent
results among different database engines. But for singular associations this
behavior is not needed since we will have one record to return. As this
ORDER BY option can lead some performance issues we are removing it for singular
associations accessors.
Fixes #12623.
|
| |
| |
| |
| | |
rather than allocating a new Relation, just make the AST directly
|
| | |
|
|\ \
| | |
| | |
| | |
| | | |
derikson/collection_proxy_select_with_multiple_args
Change CollectionProxy#select to take the same arguments as ActiveRecord::select
|
| | |
| | |
| | |
| | |
| | |
| | | |
arguments.
This makes the arguments the same as ActiveRecord::QueryMethods::select.
|
|\ \ \
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
Fix for #13437
Conflicts:
activerecord/CHANGELOG.md
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
a8 introduced a regression in includes/preloades
by calling `read_attribute` on an association when preloading takes places, instead of using loaded records in `association.target`.
tl;dr
Records are not made properly available via `read_attribute` when preloding in simultaneous,
but value of `@loaded` is already set true, and records concatenated in `association.target` on an association object.
When `@loaded` is true we return an object of `AlreadyLoaded` in preload_for. In `AlreadyLoaded` to return preloaded
records we make wrong use of `read_attribute`, instead of `target` records.
The regression is fixed by making use of the loaded records in `association.target` when the preloading takes place.
Fixes #13437
|
|/ / /
| | |
| | |
| | |
| | | |
Outer joins were being built on the root relation klass rather than the
one specified in the join dependency root
|
| | |
| | |
| | |
| | | |
Fixes: #13445
|
|\ \ \
| | | |
| | | | |
fix CollectionAssociation's comments
|
| | |/
| |/|
| | |
| | | |
AssociationProxy to match changes for 3.1 removing Association proxy.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Assigning nil to a polymorphic belongs_to would nullify its _id field by
not its _type field.
Fixes failing test from c141dfc838a5dca9f197814410fa5d44c143129c.
Regression from 1678e959e973de32287b65c52ebc6cce87148951.
|
| | | |
|
| | | |
|
| | | |
|
| | | |
|
| | | |
|
| | | |
|
| | |
| | |
| | |
| | |
| | | |
calling replace_keys could possibly do a nil check twice, this commit
reduces it to once.
|
| | |
| | |
| | |
| | |
| | | |
methods that call set_inverse_instance with a record will not have to
pay the cost of a nil check on every call
|
| | | |
|
| | |
| | |
| | |
| | |
| | | |
activerecord-deprecated_finders expects the parameters denormalized in
its initialize method
|
| | |
| | |
| | |
| | | |
This is to get activerecord-deprecated_finders work again
|
| | | |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
It is needed for activerecord-depecated_finders
This reverts commit dcff027a5242b20c0c90eb062dddb22ccf51aed9, reversing
changes made to 3a2093984ff49d86db1efeff0c7581e788ecfb9f.
|
| | |
| | |
| | |
| | | |
It is need in activerecord-deprecated_finders
|
| | | |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Example: Given you have a comments model with a polymorphic commentable
association (e.g. books and songs) with the touch option set.
Every time you update a comment its commentable should be touched.
This was working when you changed attributes on the comment or when you
moved the comment from one book to another. However, it was not working
when moving a comment from a book to a song. This is now fixed.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Previously, the `has_one` macro incorrectly accepts the `counter_cache` option
due to a bug, although that options was never supported nor functional on
`has_one` and `has_one ... through` relationships. It now correctly raises an
`ArgumentError` when passed that option.
For reference, this bug was introduced in 52f8e4b9.
|
| | | |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Fixes #12812
Raise `ActiveRecord::RecordNotDestroyed` when a child marked with
`dependent: destroy` can't be destroyed.
The following code:
```ruby
class Post < ActiveRecord::Base
has_many :comments, dependent: :destroy
end
class Comment < ActiveRecord::Base
before_destroy do
return false
end
end
post = Post.create!(comments: [Comment.create!])
post.comments = [Comment.create!]
````
would result in a `post` with two `comments`.
With this commit, the same code would raise a `RecordNotDestroyed`
exception, keeping the `post` with the same `comment`.
|
|\ \ \
| |/ /
|/| |
| | |
| | |
| | | |
Conflicts:
activesupport/lib/active_support/core_ext/hash/deep_merge.rb
activesupport/lib/active_support/core_ext/hash/keys.rb
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
According to our guideline, we leave 1 space between `#` and `=>`, so we
want `# =>` instead of `#=>`.
Thanks to @fxn for the suggestion.
[ci skip]
|
|\ \ \
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
Checks to see if the record contains the foreign_key to set the inverse automatically
Conflicts:
activerecord/CHANGELOG.md
|
| |/ /
| | |
| | |
| | | |
automatically
|
| | |
| | |
| | |
| | |
| | | |
when destroying a record on a has_many :through association.
:destroy method has own counter_cache callbacks.
|
|/ / |
|
|\ \
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Renamed generated_feature_methods to generated_association_methods.
Conflicts:
activerecord/lib/active_record/associations/builder/association.rb
activerecord/lib/active_record/associations/builder/singular_association.rb
activerecord/test/cases/base_test.rb
|
| | | |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
was using nullify strategy
This caused a regression in applications trying to upgrade.
Also if the user set the dependent option as destroy he expects to get
the records removed from the database.
|
| | |
| | |
| | |
| | | |
Fixes: #12242, #9517, #10240
|
| | | |
|
| | | |
|
| | |
| | |
| | |
| | | |
This lets us avoid the constant calls to Array#<<
|
| | | |
|