aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations
Commit message (Collapse)AuthorAgeFilesLines
...
* | | 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
| | | | |
* | | | | Merge branch 'master' into adequaterecordAaron Patterson2014-04-202-33/+15
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * master: (74 commits) [ci skip] builtin -> built-in Fix code indentation and improve formatting Grammar fix in Getting Started Guide Make URL escaping more consistent Optimize URI escaping Always escape string passed to url helper. Remove statement assuming coffee shop/public space wifi is inherently insecure Don't rely on Arel master in bug report template [ci skip] wrap methods in backticks [ci skip] "subhash" --> "sub-hash" multibyte_conformance.rb --> multibyte_conformance_test.rb Fix inconsistent behavior from String#first/#last `@destroyed` should always be set to `false` when an object is duped. remove warning `warning: ambiguous first argument; put parentheses or even spaces` :uglify -> :uglifier Regression test for irregular inflection on has_many Singularize association names before camelization Fix spelling and proper nouns Optimize select_value, select_values, select_rows and dry up checking whether to exec with cache for Postgresql adapter Include default rails protect_from_forgery with: :exception ... Conflicts: activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
| * | | | Hide BelongsToAssociation#increment_counters and #decrement_countersJean Boussier2014-04-152-3/+2
| | | | |
| * | | | Use inheritance chain instead of callbacks to increment counter caches after ↵Jean Boussier2014-04-141-16/+0
| | | | | | | | | | | | | | | | | | | | destroy
| * | | | Use inheritance chain instead of callbacks to increment counter caches after ↵Jean Boussier2014-04-142-16/+15
| | |/ / | |/| | | | | | | | | | create
* | | | use cache queries for hm:t associationsAaron Patterson2014-04-151-1/+1
| | | |
* | | | cache scope building on associationsAaron Patterson2014-04-142-7/+64
| | | | | | | | | | | | | | | | SQL statements for querying associations are now cached
* | | | Merge branch 'master' into adequaterecordAaron Patterson2014-04-143-7/+12
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * master: (70 commits) [ci skip] Added link to ruby-lang.org installation. Use the index on hidden field `collection_check_boxes` respects `:index` option for the hidden filed name. docs, double meaning of `serialize` argument. Closes #14284. Just call read_attribute, no need to use `send`. - Fix lingering reference to `:text` instead of the newer `:plain` - Section references `form_tag` instead of the `form_for` used in the example again, read_attribute is public, so just call it read_attribute is public, so we should just call it Disable assest cache store in docs [ci skip] Make counter cache decrementation on destroy idempotent Write the failing test case for concurrent counter cache [ci skip] Use plain underscore instead of "\_". Update documentation to use Rails.application instead Add a changelog entry for #14546 [ci skip] Move tests for deep_dup and duplicable to object directory Missing 'are' in note - [ci skip] CollectionHelpers now accepts a readonly option Fix a few typos [ci skip] Bundle tzinfo-data on :x64_mingw (64-bit Ruby on Windows). don't bother with an offset if the offset is zero ...
| * | | Merge pull request #14735 from byroot/idempotent-counter-cachesAaron Patterson2014-04-141-4/+5
| |\ \ \ | | | | | | | | | | Idempotent counter caches, fix concurrency issues with counter caches
| | * | | Make counter cache decrementation on destroy idempotentJean Boussier2014-04-131-4/+5
| | | | |
| * | | | again, read_attribute is public, so just call itAaron Patterson2014-04-131-1/+1
| | | | |
| * | | | read_attribute is public, so we should just call itAaron Patterson2014-04-131-1/+1
| |/ / /
| * | | Merge pull request #12829 from iantropov/issue_insert_via_hmt_scope_3548Rafael Mendonça França2014-04-101-1/+5
| |\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix insertion of records for hmt association with scope Conflicts: activerecord/CHANGELOG.md
| | * | | Fix insertion of records for hmt association with scope, fix #3548Ivan Antropov2013-11-171-1/+5
| | | | |
* | | | | Merge branch 'master' into adequaterecordAaron Patterson2014-04-075-46/+22
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * master: (122 commits) Rails.application should be set inside before_configuration hook remove check for present? from delete_all Remove useless begin..end Build the reverse_order on its proper method. Use connection-specific bytea escaping Ignore order when doing count. make enums distinct per class Remove unused `subclass_controller_with_flash_type_bar` var from flash test. fix CollectionProxy delete_all documentation Added OS X specific commands to installation guide [ci skip] Recommended using homebrew for installing MySQL and PostgreSQL Fix setup of adding _flash_types test. Use SVG version of travis build status badge [skip ci] W3C CSP document moved to gihub.io URL [ci skip] sprockets-rails was released Fix the test defining the models in the right place Add CHANGELOG entry for #11650 [ci skip] Declare the assets dependency Use sass-rails 4.0.3 Make possible to use sprockets-rails 2.1 add missing parentheses to validates_with documentation [skip ci] ...
| * | | | remove check for present? from delete_alleileencodes2014-04-071-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | Passing in a blank string is a bug so there's no reason to check for a blank string.
| * | | | fix CollectionProxy delete_all documentationeileencodes2014-04-061-6/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This method no longer returns an array of all records that have been removed. Correct documentation to reflect this change. See issue 14546
| * | | | Merge pull request #11650 from prathamesh-sonpatki/renameRafael Mendonça França2014-04-042-7/+7
| |\ \ \ \ | | | | | | | | | | | | | | | | | | Renamed private methods _create_record and _update_record