aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations
Commit message (Collapse)AuthorAgeFilesLines
...
* | | Do not try to set the foreign_key again on has_many throughRafael Mendonça França2014-06-091-1/+1
| | | | | | | | | | | | | | | | | | | | | Integration tests are inside protected_attributes test suite. Fixes #15496 Fixes rails/protected_attributes#35
* | | Remove a long gone :order option from has_one's valid_options.thedarkone2014-06-091-1/+1
| | |
* | | Use null column for association key typesSean Griffin2014-06-041-4/+2
| | |
* | | Merge pull request #15482 from laurocaetano/fix-regression-for-eager-loadCarlos Antonio da Silva2014-06-041-2/+4
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | Fix regression on eager loading association based on SQL query rather than existing column. Conflicts: activerecord/CHANGELOG.md
| * | | Fix regression on eager loading association based on SQL query ratherLauro Caetano2014-06-031-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | than existing column. Fixes #15480.
* | | | reuse available belongs_to? methodeileencodes2014-06-032-4/+3
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | Reflection has a `belongs_to?` method. Instead of checking for `macro == :belongs_to` throughout the source reuse existing method. I also bumped `foreign_key_present?` method onto on line because the `belongs_to?` makes it shorter than other longer lines in the same class.
* | | fix polymorphic? method and reuse iteileencodes2014-06-022-2/+2
| | | | | | | | | | | | | | | | | | Fix polymorphic to check for `options[:polymorphic]` instead of `options.key? :polymorphic` and then reuse the method `polymorphic?` method instead of constantly checking the same `options[:polymorphic]`.
* | | Merge pull request #14834 from al2o3cr/issue14155Aaron Patterson2014-05-271-1/+11
|\ \ \ | | | | | | | | Correctly alias table names when joining more than once
| * | | WIP: pass existing joins to construct_join_dependencyMatt Jones2014-05-161-1/+11
| | | |
* | | | Merge pull request #15301 from zzak/issue_15212Rafael Mendonça França2014-05-261-0/+1
|\ \ \ \ | | | | | | | | | | | | | | | Skip if the association was already loaded.
| * | | | Skip if the association was already loaded.Zachary Scott2014-05-241-0/+1
| | |_|/ | |/| |
* / | | Merge pull request #15210 from arthurnn/fix_hbtm_reflectionArthur Neves2014-05-244-5/+6
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | Fix habtm reflection Conflicts: activerecord/CHANGELOG.md activerecord/lib/active_record/counter_cache.rb activerecord/lib/active_record/reflection.rb activerecord/test/cases/reflection_test.rb
* | | Merge pull request #14855 from laurocaetano/fix_polymorphic_with_string_keyYves Senn2014-05-211-4/+25
|\ \ \ | | | | | | | | | | | | Fix polymorphic eager load with foreign_key as String.
| * | | Fix polymorphic eager load with foreign_key as String.Lauro Caetano2014-05-201-2/+17
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | Prevented belongs_to: touch propagating up if there are no changes being savedBrock Trappitt2014-05-211-1/+1
| | |
* | | fix multiple hash preloads. Fixes #14994Aaron Patterson2014-05-201-6/+7
| | |
* | | Fixed the inferred table name for HABTM within a schemaEric Chahin2014-05-201-1/+1
| | | | | | | | | | | | Fixes #14824.
* | | early return on delete and destroy methodseileencodes2014-05-181-0/+2
|/ / | | | | | | | | | | When delete or destroy is called on all records nothing is deleted or destroyed. Intead of running through the code and still not deleteing anything, we should early return
* | Remove the assignment for real this time.Zachary Scott2014-05-161-2/+2
| | | | | | | | | | | | cc: https://github.com/rails/rails/commit/a11e2fcff8cdc9691b977d8330abe63024f8c732#commitcomment-6353614 and 0369dbf
* | prepend mutates the string so we can remove the assignmentRafael Mendonça França2014-05-161-1/+1
| |
* | Don't use Active Support where it is not needed.Rafael Mendonça França2014-05-141-1/+3
| | | | | | | | | | parent_name is a string of nil, never a blank string so we don't need to use presence.
* | Merge pull request #14871 from kassio/kb-fixes-namespaced-habtmRafael Mendonça França2014-05-141-1/+5
|\ \ | | | | | | | | | | | | | | | | | | Fix how to compute class name on habtm namespaced. Conflicts: activerecord/CHANGELOG.md
| * | Fix how to compute class name on habtm namespaced.Kassio Borges2014-05-131-1/+5
| | | | | | | | | | | | | | | | | | Thank's for @laurocaetano for the help with tests. :smiley: Fixes #14709
* | | remove count vareileencodes2014-05-131-4/+2
| | | | | | | | | | | | this change was unneccsary as nothing was gained from it
* | | rename delete_all_records to delete_or_nullify_all_recordseileencodes2014-05-133-8/+4
| | | | | | | | | | | | | | | | | | | | | Rename delete_all_records because this name better describes what the method is doing. We can then remove :all from the hm:t version and pull out the unoptimized call to load_target in delete_records and pass it directly.
* | | remove need for :all symboleileencodes2014-05-131-13/+6
| | | | | | | | | | | | | | | | | | Refactor delete_count method to only handle delete_all or nullify/nil cases and not destroy and switch to if/else rather than case statement. This refactoring allows removal of :all symbol usage.
* | | begin refactoring delete_records methodeileencodes2014-05-133-13/+30
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | Refactor by creating two methods delete_all_records and delete_records to be called by delete_all and delete (or destroy) respectively. This reduces the number of conditionals required to handle _how_ records get deleted. The new delete_count method handles how scope is applied to which delete action. A delete_all_records method also has to be called in has_many_through association because of how the methods are chained. This will be refactored later on.
* | deprecate, join, preload, eager load of instance dependent associations.Yves Senn2014-05-102-0/+2
| | | | | | | | | | | | | | Closes #15024. These operations happen before instances are created. The current behavior is misleading and can result in broken behavior.
* | Fixed HABTM's CollectionAssociation sizeFred Wu2014-05-081-1/+1
| | | | | | | | | | 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.
* | Follow-up to #14990 [ci skip]Jon Atack2014-05-071-10/+9
| | | | | | | | | | | | | | | | Rewrite to avoid 'we'/'you', add missing period, and keep lines at 80 chars. Cheers :) Improve readability with help from @senny [ci skip]
* | Merge pull request #14982 from eric-chahin/GBV_refactorRafael Mendonça França2014-05-061-8/+1
|\ \ | | | | | | Refactored AssociationScope#get_bind_values
| * | Refactor AssociationScope#get_bind_valuesEric Chahin2014-05-051-8/+1
| | | | | | | | | | | | Added #join_id_for(owner) to reflection to avoid accessing the source_macro
* | | Fixed grammarFred Wu2014-05-061-1/+1
| | |
* | | refactor and clean up delete_all methodeileencodes2014-05-051-9/+1
|/ / | | | | | | | | | | | | | | Now that delete_all with destroy or delete_all dependency behave the same we no longer need this conditional. This means we can remove the new delete_all_with_dependency method I added and go straight to delete_records from delete_all, passing :all and the dependent directly.
* | flip conditional in delete_all to handle nullify bettereileencodes2014-04-281-3/+3
| | | | | | | | | | | | | | | | Nullify (or nil dependency) was doing the same thing delete_all was doing in issue #14546, creating a large IN statement if the association was loaded. Loaded and not loaded associations should behave the same. The IN statement is also not great because it's inefficient.
* | simplify the delete all w/ dependency methodeileencodes2014-04-281-3/+3
| | | | | | | | | | | | | | After reviewing this code I realized the conditional that was there previously was basically saying if the dependency is not delete all. This is a better, cleaner, and clearer way to write this method.
* | remove unnecessary code from delete methodeileencodes2014-04-281-10/+2
| | | | | | | | | | Now that we have a new method delete_all_with_dependency this coupled conditional is no longer needed.
* | write a new method to be accessed from delete_alleileencodes2014-04-281-1/+9
| | | | | | | | | | | | The delete method is very coupled with delete all even though only a portion of the conditionals apply. Decoupling this will make the code easier to understand and manipulate.
* | Merge pull request #14853 from kassio/kb-fix-custom-join-table-habtmYves Senn2014-04-251-1/+1
|\ \ | | | | | | Fix to use custom join table in habtm
| * | Fix custom join_table name on habtm reflectionsKassio Borges2014-04-251-1/+1
| | | | | | | | | | | | | | | | | | When used a custom join_table name on a habtm, rails was not saving it on Reflections. This causes a problem when rails loads fixtures, because it uses the reflections to set database with fixtures.
* | | Merge branch 'master' into adequaterecordAaron Patterson2014-04-253-4/+6
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * master: (28 commits) move AR length validation tests into separate test-case. No need for trailing slash on migration path. reset `@arel` when modifying a Relation in place. PostgreSQL Timestamps always map to `:datetime`. [ci skip] Improve formatting and yml Fix a typo in the doc of forty_two AR FinderMethod Improve readability of contributing to rails guide. [ci skip] Precompile the image we're referencing, too. `ActiveRecord::Base.no_touching` no longer triggers callbacks or start empty transactions. Fixed an issue with migrating legacy json cookies. Correct comment [ci skip] Perfer to define methods instead of calling test Fix syntax error Add CHANGELOG entry for #14757 [ci skip] Fix run-on sentences and improve grammar [skip ci] Add test for using ActionView::Helpers::FormHelper.label with block and html select! renamed to avoid name collision Array#select! Rearrange deck chairs on the titanic. Organize connection handling test cases. Change favicon_link_tag helper mimetype from image/vnd.microsoft.icon to image/x-icon. ActionController::Renderers documentation fix ...
| * | reset `@arel` when modifying a Relation in place.Yves Senn2014-04-241-1/+1
| | | | | | | | | | | | /cc @tenderlove
| * | Merge pull request #14757 from estsauver/14752Rafael Mendonça França2014-04-221-1/+1
| |\ \ | | | | | | | | Fix behavior of select! to be consistent with select #14752
| | * | select! renamed to avoid name collision Array#select!Earl J St Sauver2014-04-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes #14752 Select mimics the block interface of arrays, but does not mock the block interface for select!. This change moves the api to be a private method, _select!.
| * | | Merge pull request #14573 from habermann24/has_many_through_fixRafael Mendonça França2014-04-221-2/+4
| |\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Properly handle scoping with has_many :through. Fixes #14537. Conflicts: activerecord/CHANGELOG.md activerecord/test/cases/associations/has_many_through_associations_test.rb
| | * | | Minor improvement: Use the merge method on the relation instead of ↵Jan Habermann2014-04-031-1/+1
| | | | | | | | | | | | | | | | | | | | instance_eval directly.
| | * | | Simplify the code in target_scopeJan Habermann2014-04-031-5/+2
| | | | |
| | * | | Properly handle scoping with has_many :through. Fixes #14537.Jan Habermann2014-04-031-2/+7
| | | | |
* | | | | use statement cache for belongs_to relationsAaron Patterson2014-04-222-2/+13
| | | | |
* | | | | extract record fetching to a method for belongs_toAaron Patterson2014-04-221-1/+5
| | | | |