aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/collection_association.rb
Commit message (Collapse)AuthorAgeFilesLines
* Revert "Perf: Don't load the association for #delete_all."Jon Leighton2012-06-071-12/+2
| | | | | | | | | | This reverts commit b98d1e21635d8776de8893cc09bd86c71f6c78f0. Closes #6609 Conflicts: activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
* Ensure that CollectionAssociation#replace returns proper targetPiotr Sarnacki2012-05-191-1/+1
| | | | | | | | The fix commited in e2a070c was returning the `new_target`, as a try to return whatever user replaced association with. The problem is, the resulting association target may be ordered differently. In such case we want to return the target that will be later used for that association.
* Perf: Don't load the association for #delete_all.Jon Leighton2012-05-181-2/+12
| | | | | | | | Bug #6289 Conflicts: activerecord/test/cases/associations/has_many_associations_test.rb
* Fix CollectionAssociation#replace to return new target (closes #6231)Piotr Sarnacki2012-05-161-0/+2
| | | | | | Conflicts: activerecord/test/cases/associations/has_many_associations_test.rb
* Merge pull request #4783 from gregolsen/ids_reader_fixJon Leighton2012-01-311-1/+1
| | | | ids_reader method fixed, test added to has_many association (for PostgreSQL)
* bypass preloading for ids_readerSergey Nartimov2011-12-181-2/+10
| | | | | when fetching ids for a collection, bypass preloading to avoid the unnecessary performance overhead
* Fix #3672 again (dependent: delete_all perf)Jon Leighton2011-12-141-0/+7
|
* load has_many associations keyed off a custom primary key if that key is ↵Brian Samson2011-11-251-1/+1
| | | | present but the record is unsaved
* Merge pull request #3507 from jmazzi/issue-3503Jeremy Kemper2011-11-031-2/+6
| | | | Preserve SELECT columns on the COUNT for finder_sql when possible
* Changed a few instances of of words in the API docs written in British ↵Oemuer Oezkir2011-07-241-1/+1
| | | | | | English to American English(according to Weber)
* Fix bug in collection_singular_ids on has many through association with ↵Anatoliy Lysenko2011-07-061-1/+1
| | | | | | | | | | | | | | | | conditions and includes, when condtions references tables from includes. Test fail because of invalid sql: ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column: comments.id: SELECT "posts".id FROM "posts" INNER JOIN "readers" ON "posts"."id" = "readers"."post_id" WHERE "readers"."person_id" = 1 AND (comments.id is null) Bug described in github#925 This commit will revert fix from https://github.com/rails/rails/commit/3436fdfc12d58925e3d981e0afa61084ea34736c , but tests is ok. Bug described in #6569 ticket.
* Fixed CollectionAssociation#find to be compatible with Array#findBogdan Gusiev2011-07-051-3/+7
| | | | | In order to make CollectionAssociation behave closer to Array Add the ability to pass block to #find method just like Array#find does.
* Assign the association attributes to the associated record before the ↵Jon Leighton2011-06-301-6/+0
| | | | before_initialize callback of the record runs. Fixes #1842.
* Replace inline lambdas with named methodsJon Leighton2011-06-121-29/+42
|
* Don't wrap operations on collection associations in transactions when they ↵benedikt2011-06-121-3/+9
| | | | are not needed, so the connection adapter does not send empty BEGIN COMMIT transactions blocks to the database.
* Don't double assign attributes - closes #1467.Andrew White2011-06-031-1/+0
|
* Only save the record once when calling create! on a collection association. ↵Jon Leighton2011-05-311-19/+21
| | | | Fixes #1360.
* Implementing @dmathieu's cleaner fix from #1425. Unfortunately he deleted ↵Jon Leighton2011-05-311-8/+5
| | | | the branch so I cannot just merge it.
* Adding comment to work with 1.8.7. Nested Attribute fix.Arun Agrawal2011-05-311-0/+3
|
* Fix nested attribute for memory record.Arun Agrawal2011-05-311-1/+5
|
* Remove extra white spaces on ActiveRecord docs.Sebastian Martinez2011-05-231-1/+1
|
* Pass the attribute and option hashes to build_associationAndrew White2011-05-171-2/+6
| | | | | | | The build_association method was added as an API for plugins to hook into in 1398db0. This commit restores this API and the ability to override class.new to return a subclass based on a virtual attribute in the attributes hash.
* These extra array operations appear to be unnecessary. Reasoning:Jon Leighton2011-05-141-8/+2
| | | | | * It is not necessary to subtract 'id' from the list of copied attributes because record and mem_record are equal, so therefore their id attributes are also equal (so there is no harm in copying it, and this reduces the complexity of the code) * It is not necessary to intersect the attribute names, since record and mem_record are equal, so they have the same id and class, so they have the same columns in the database. If record has non-column attributes then it seems reasonable to also copy them onto mem_record (though I am not sure what situation this would ever happen in)
* CollectionAssociation#merge_target_lists should write to the underlying ↵Jon Leighton2011-05-141-5/+2
| | | | attributes when copying, rather than using the assignment method
* An attempt to make CollectionAssociation#merge_target_lists make more sense.Jon Leighton2011-05-141-16/+35
|
* Instead of doing find(:all) which does scoped.find(:all) which does ↵Jon Leighton2011-05-131-1/+1
| | | | scoped.all, just do scoped.all.
* Remove pointless rescue (it doesn't happen anywhere in the tests, and I ↵Jon Leighton2011-05-131-9/+1
| | | | can't see a way that it would happen ever)
* Modified CollectionAssociation to refer to the new class name.Michael Ebens2011-05-111-1/+1
|
* Remove unnecessary '|| {}'Jon Leighton2011-05-101-1/+1
|
* Don't use mass-assignment protection when applying the ↵Jon Leighton2011-05-101-2/+4
| | | | scoped.scope_for_create. Fixes #481.
* Fix #480. Passing nil to create association works.José Valim2011-05-101-1/+1
|
* Revert "b9ea751d0e56bd00d341766977a607ed3f7ddd0f".José Valim2011-05-101-26/+27
| | | | | Wrapping each Record.associations.build in a transaction is going to make several unneeded queries. Reverting this commit also fixes #479.
* singular and collection relations in AR can now specify mass-assignment ↵Josh Kalderimis2011-05-011-10/+10
| | | | security options (:as and :without_protection) in build, create and create! methods.
* Removing the scope-caching which happens on association proxies, because the ↵Jon Leighton2011-04-121-12/+0
| | | | query is already cached by the query cacher. For formalised proof see http://www.youtube.com/watch?v=wDefXLb-FDs
* Move the code which builds a scope for through associations into a generic ↵Jon Leighton2011-03-101-13/+0
| | | | AssociationScope class which is capable of building a scope for any association.
* Use proper objects to do the work to build the associations (adding methods, ↵Jon Leighton2011-02-211-0/+39
| | | | callbacks etc) rather than calling a whole bunch of methods with rather long names.
* Delegate Association#options to the reflection, and replace ↵Jon Leighton2011-02-211-24/+24
| | | | 'reflection.options' with 'options'. Also add through_options and source_options methods for through associations.
* Associations - where possible, call attributes methods rather than directly ↵Jon Leighton2011-02-211-49/+49
| | | | accessing the instance variables
* Split AssociationProxy into an Association class (and subclasses) which ↵Jon Leighton2011-02-181-0/+510
manages the association, and a CollectionProxy class which is *only* a proxy. Singular associations no longer have a proxy. See CHANGELOG for more.