aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations/has_many_through_associations_test.rb
Commit message (Collapse)AuthorAgeFilesLines
...
* used flat_map instead of map.flattenKarunakar (Ruby)2013-07-251-1/+1
|
* Make sure that a joins Relation can be merged with has_many :through + ↵Akira Matsuda2013-07-101-0/+6
| | | | | | association proxy Closes #11248.
* Do not invoke callbacks when delete_all is calledNeeraj Singh2013-06-301-0/+34
| | | | | | | | | | | Method `delete_all` should not be invoking callbacks and this feature was deprecated in Rails 4.0. This is being removed. `delete_all` will continue to honor the `:dependent` option. However if `:dependent` value is `:destroy` then the default deletion strategy for that collection will be applied. User can also force a deletion strategy by passing parameter to `delete_all`. For example you can do `@post.comments.delete_all(:nullify)`
* has_many through obeys order on through associationNeeraj Singh2013-04-041-1/+7
| | | | fixes #10016
* Prevent Relation#merge from collapsing wheres on the RHSJon Leighton2013-01-271-0/+7
| | | | | | | | | | | | | | | | | | | | | | | This caused a bug with the new associations implementation, because now association conditions are represented as Arel nodes internally right up to when the whole thing gets turned to SQL. In Rails 3.2, association conditions get turned to raw SQL early on, which prevents Relation#merge from interfering. The current implementation was buggy when a default_scope existed on the target model, since we would basically end up doing: default_scope.merge(association_scope) If default_scope contained a where(foo: 'a') and association_scope contained a where(foo: 'b').where(foo: 'c') then the merger would see that the same column is representated on both sides of the merge and collapse the wheres to all but the last: where(foo: 'c') Now, the RHS of the merge is left alone. Fixes #8990
* Revert "Merge pull request #8989 from robertomiranda/use-rails-4-find-by"Guillermo Iguaran2013-01-181-1/+1
| | | | | This reverts commit 637a7d9d357a0f3f725b0548282ca8c5e7d4af4a, reversing changes made to 5937bd02dee112646469848d7fe8a8bfcef5b4c1.
* User Rails 4 find_byrobertomiranda2013-01-181-1/+1
|
* Rename update_attributes method to update, keep update_attributes as an aliasAmparo Luna + Guillermo Iguaran2013-01-031-1/+1
|
* Fix for has_many_through counter_cache bugMatthew Robertson2012-12-141-0/+11
| | | | | | This commit fixes reported issue #7630 in which counter caches were not being updated properly when replacing has_many_through relationships
* Merge and add tests related to 5215Vipul A M2012-11-121-6/+13
|
* remove duplicated require statements in AR test casesYves Senn2012-10-091-1/+0
|
* Revert "Use flat_map { } instead of map {}.flatten"Santiago Pastorino2012-10-051-1/+1
| | | | | | | | | | | This reverts commit abf8de85519141496a6773310964ec03f6106f3f. We should take a deeper look to those cases flat_map doesn't do deep flattening. irb(main):002:0> [[[1,3], [1,2]]].map{|i| i}.flatten => [1, 3, 1, 2] irb(main):003:0> [[[1,3], [1,2]]].flat_map{|i| i} => [[1, 3], [1, 2]]
* Use flat_map { } instead of map {}.flattenSantiago Pastorino2012-10-051-1/+1
|
* Count returns 0 without querying if parent is not savedFrancesco Rodriguez2012-10-031-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | Patches `CollectionAssociation#count` to return 0 without querying if the parent record is new. Consider the following code: class Account has_many :dossiers end class Dossier belongs_to :account end a = Account.new a.dossiers.build # before patch a.dossiers.count # SELECT COUNT(*) FROM "dossiers" WHERE "dossiers"."account_id" IS NULL # => 0 # after a.dosiers.count # fires without sql query # => 0 Fixes #1856.
* Merge pull request #7251 from rails/integrate-strong_parametersDavid Heinemeier Hansson2012-09-181-15/+0
|\ | | | | Integrate strong_parameters in Rails 4
| * Remove mass assignment security from ActiveRecordGuillermo Iguaran2012-09-161-15/+0
| |
* | Fix collection= on hm:t join models when unsavedErnie Miller2012-09-171-0/+5
|/ | | | | | If assigning to a has_many :through collection against an unsaved object using the collection=[<array_of_items>] syntax, the join models were not properly created, previously.
* ActiveRecord::Base.all returns a Relation.Jon Leighton2012-07-271-2/+2
| | | | | | | | | | | Previously it returned an Array. If you want an array, call e.g. `Post.to_a` rather than `Post.all`. This is more explicit. In most cases this should not break existing code, since Relations use method_missing to delegate unknown methods to #to_a anyway.
* Deprecate update_column in favor of update_columns.Rafael Mendonça França2012-07-241-2/+2
| | | | Closes #1190
* rm unnecessary testJon Leighton2012-07-201-7/+0
| | | | | interpolation is no longer a thing separate from "normal" assoc conditions.
* remove calls to find(:first), find(:last) and find(:all)Jon Leighton2012-04-261-3/+3
|
* remove deprecate #calculate callsJon Leighton2012-04-261-1/+1
|
* Merge pull request #5289 from rafaelfranca/fix-through-associationsJon Leighton2012-03-081-4/+20
|\ | | | | Fix has_many through associations when mass_assignment_sanitizer is strict
| * Not need to pass join attributes to association buildRafael Mendonça França2012-03-071-3/+2
| |
| * Add test case to has_many through association when mass_assignment_sanitizer isRafael Mendonça França2012-03-051-4/+21
| | | | | | | | :strict
* | Add tests to test that through associations are not readonly, and we can ↵kuahyeow2012-03-081-0/+11
|/ | | | update the records we retrive from the association
* The primary key is always initialized in the @attributes hash to nil (unlessAaron Patterson2012-01-251-1/+1
| | | | another value has been specified).
* Deprecate inferred JOINs with includes + SQL snippets.Jon Leighton2012-01-161-1/+1
| | | | | | See the CHANGELOG for details. Fixes #950.
* Revert "Deprecate implicit eager loading. Closes #950."Jon Leighton2012-01-161-1/+1
| | | | This reverts commit c99d507fccca2e9e4d12e49b4387e007c5481ae9.
* Deprecate implicit eager loading. Closes #950.Jon Leighton2011-12-291-1/+1
|
* bypass preloading for ids_readerSergey Nartimov2011-12-181-0/+6
| | | | | when fetching ids for a collection, bypass preloading to avoid the unnecessary performance overhead
* Remove all revelant through records.Jon Leighton2011-11-031-0/+15
| | | | | | | | | If a record is removed from a has_many :through, all of the join records relating to that record should also be removed from the through association's target. (Previously the records were removed in the database, but only one was removed from the in-memory target array.)
* Fix adding multiple instances of the same record to a has_many :through.Jon Leighton2011-11-031-0/+10
| | | | Fixes #3425.
* Fix #3247.Jon Leighton2011-11-031-0/+5
| | | | | Fixes creating records in a through association with a polymorphic source type.
* The join_nodes must be passed to the JoinDependency initializer and ↵Jon Leighton2011-08-291-0/+4
| | | | therefore counted by the alias tracker. This is because the association_joins are aliased on initialization and then the tables are cached, so it is no use to alias the join_nodes later. Fixes #2556.
* Ensure empty has_many :through association preloaded via joins is marked as ↵Jon Leighton2011-08-151-0/+8
| | | | loaded. Fixes #2054.
* Fix bug in collection_singular_ids on has many through association with ↵Anatoliy Lysenko2011-07-061-0/+5
| | | | | | | | | | | | | | | | 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.
* please use ruby -I lib:test path/to/test.rb, or export RUBY_OPTAaron Patterson2011-06-061-1/+1
|
* Refactor Active Record test connection setup. Please see the ↵Jon Leighton2011-06-041-1/+1
| | | | 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.
* add tests surrounding behavior of save and save! for associations that have ↵Aaron Patterson2011-05-241-0/+26
| | | | validation errors
* adding a test for create! with invalid associationsAaron Patterson2011-05-241-0/+9
|
* do not bother with assert_nothing_raised, the test will fail and we get a ↵Aaron Patterson2011-05-241-3/+1
| | | | better trace without it
* Add failing test case for issue 796Joey Butler2011-05-241-0/+9
|
* fixing more test warnings in 1.9.3Aaron Patterson2011-04-301-1/+1
|
* Fix test_associate_existing in has_many_through_associations_test on mysql ↵Jon Leighton2011-04-171-1/+1
| | | | and postgresql
* Added new #update_column method.Sebastian Martinez2011-03-271-2/+2
| | | | Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* Revert "Removed #update_attribute method. New #update_column method."Sebastian Martinez2011-03-271-2/+2
| | | | | | This reverts commit 45c233ef819dc7b67e259dd73f24721fec28b8c8. Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* Removed #update_attribute method. New #update_column method.Sebastian Martinez2011-03-261-2/+2
| | | | Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* Merge branch 'master' into nested_has_many_throughJon Leighton2011-03-041-14/+302
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: activerecord/CHANGELOG activerecord/lib/active_record/association_preload.rb activerecord/lib/active_record/associations.rb activerecord/lib/active_record/associations/class_methods/join_dependency.rb activerecord/lib/active_record/associations/class_methods/join_dependency/join_association.rb activerecord/lib/active_record/associations/has_many_association.rb activerecord/lib/active_record/associations/has_many_through_association.rb activerecord/lib/active_record/associations/has_one_association.rb activerecord/lib/active_record/associations/has_one_through_association.rb activerecord/lib/active_record/associations/through_association_scope.rb activerecord/lib/active_record/reflection.rb activerecord/test/cases/associations/has_many_through_associations_test.rb activerecord/test/cases/associations/has_one_through_associations_test.rb activerecord/test/cases/reflection_test.rb activerecord/test/cases/relations_test.rb activerecord/test/fixtures/memberships.yml activerecord/test/models/categorization.rb activerecord/test/models/category.rb activerecord/test/models/member.rb activerecord/test/models/reference.rb activerecord/test/models/tagging.rb
| * Allow building and then later saving has_many :through records, such that ↵Jon Leighton2011-02-181-0/+18
| | | | | | | | the join record is automatically saved too. This requires the :inverse_of option to be set on the source association in the join model. See the CHANGELOG for details. [#4329 state:resolved]