| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
| |
Need to define #reset on CollectionProxy.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Suppose Man has_many interests, and inverse_of is used.
Man.first.interests.first.man will correctly execute two queries,
avoiding the need for a third query when Interest#man is called. This is
because CollectionAssociation#first calls set_inverse_instance.
However Man.first.interests.where("1=1").first.man will execute three
queries, even though this is obviously a subset of the records in the
association.
This is because calling where("1=1") spawns a new Relation object from
the CollectionProxy object, and the Relation has no knowledge of the
association, so it cannot set the inverse instance.
This commit solves the problem by making relations spawned from
CollectionProxies return a new Relation subclass called
AssociationRelation, which does know about associations. Records loaded
from this class will get the inverse instance set properly.
Fixes #5717.
Live commit from La Conf! :sparkles:
|
| |
|
|
|
|
|
|
|
|
| |
This reimplements the behaviour of Rails 3, as I couldn't see why we
shouldn't cache the object, and @alindeman had a good use case for
caching it:
https://github.com/rails/rails/commit/c86a32d7451c5d901620ac58630460915292f88b#commitcomment-2784312
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
Closes #7364.
Collection associations behave similar to Arrays. However there is no
way to prepend records. And to append one should use `<<`. Before this
patch `#append` and `#prepend` did not add the record to the loaded
association.
`#append` now behaves like `<<` and `#prepend` is not defined.
|
|
|
|
| |
Fixes #7418.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This can be used to get a Relation from an association.
Previously we had a #scoped method, but we're deprecating that for
AR::Base, so it doesn't make sense to have it here.
This was requested by DHH, to facilitate code like this:
Project.scope.order('created_at DESC').page(current_page).tagged_with(@tag).limit(5).scoping do
@topics = @project.topics.scope
@todolists = @project.todolists.scope
@attachments = @project.attachments.scope
@documents = @project.documents.scope
end
|
|
|
|
|
|
| |
It has been moved to active_record_deprecated_finders.
Use #to_a instead.
|
|
|
|
|
|
|
| |
It doesn't serve much purpose now that ActiveRecord::Base.all returns a
Relation.
The code is moved to active_record_deprecated_finders.
|
|
|
|
| |
Closes #1190
|
| |
|
|
|
|
| |
Base#scoped
|
|
|
|
| |
things
|
|
|
|
|
|
| |
See the CHANGELOG for details.
Fixes #950.
|
|
|
|
| |
This reverts commit c99d507fccca2e9e4d12e49b4387e007c5481ae9.
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
| |
Instead of generating association methods directly in the model
class, they are generated in an anonymous module which
is then included in the model class. There is one such module
for each association. The only subtlety is that the
generated_attributes_methods module (from ActiveModel) must
be forced to be included before association methods are created
so that attribute methods will not shadow association methods.
|
|
|
|
| |
by association extensions to access information about the association. This replaces proxy_owner etc with proxy_association.owner.
|
| |
|
|
|
|
| |
RUNNING_UNIT_TESTS file for details, but essentially you can now configure things in test/config.yml. You can also run tests directly via the command line, e.g. ruby path/to/test.rb (no rake needed, uses default db connection from test/config.yml). This will help us fix the CI by enabling us to isolate the different Rails versions to different databases.
|
| |
|
|
|
|
| |
CollectionProxy with deprecations. Fixes #1148.
|
| |
|
|
|
|
| |
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
|
|
|
|
|
|
| |
This reverts commit 45c233ef819dc7b67e259dd73f24721fec28b8c8.
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
|
|
|
|
| |
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
|
|
|
|
| |
singular associations no longer return a proxy object.
|
|
|
|
| |
manages the association, and a CollectionProxy class which is *only* a proxy. Singular associations no longer have a proxy. See CHANGELOG for more.
|
|
|
|
|
|
| |
inheritable has been changed to class_attribute. class inheritable attributes has been deprecated.
Signed-off-by: José Valim <jose.valim@gmail.com>
|
| |
|
|
|
|
| |
's/[ \t]*$//' -i {} \;)
|
|
|
|
|
|
|
|
|
|
|
|
| |
to relevant files.
Number of assertions before refactoring:
2391 tests, 7579 assertions, 0 failures, 0 errors
Number of assertions after refactoring:
2391 tests, 7579 assertions, 0 failures, 0 errors
Signed-off-by: José Valim <jose.valim@gmail.com>
|
|
|
|
|
|
| |
[#4971 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
|
|
|
|
|
|
| |
[#5153 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
|
|
|
|
|
|
|
|
| |
Loading the associate target in nested_attributes
should load most recent attributes for child
records marked for destruction
Signed-off-by: José Valim <jose.valim@gmail.com>
|
|
|
|
|
|
| |
examining the length of an array which contains false/true, hence always passing. [#4869 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
|
|
|
|
| |
Signed-off-by: wycats <wycats@gmail.com>
|
|
|
|
|
|
| |
[#4166 state:committed]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
|
|
|
|
|
|
| |
cache [#1827 state:resolved]
Signed-off-by: Joshua Peek <josh@joshpeek.com>
|
| |
|
|
|
|
| |
There are several situations it doesn't cater for, and the inconsistency isn't worth blocking 2.2.
|
|
|
|
| |
Signed-off-by: Michael Koziarski <michael@koziarski.com>
|
|
|
|
|
|
|
| |
saving and reloading the record)
Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#142 state:committed]
|
|
|
|
|
|
|
|
|
|
|
|
| |
using hash. [#474 state:resolved]"
This reverts commit e0750d6a5c7f621e4ca12205137c0b135cab444a.
Conflicts:
activerecord/CHANGELOG
activerecord/lib/active_record/associations.rb
activerecord/lib/active_record/associations/association_collection.rb
|
| |
|