aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations
Commit message (Collapse)AuthorAgeFilesLines
...
* | | :cut: remove unnecessary rescue ExceptionsAaron Patterson2015-03-051-1/+1
| |/ |/|
* | Merge pull request #19105 from amatsuda/array_takeSean Griffin2015-03-021-0/+13
|\ \ | | | | | | Preserve Array#take(n) behaviour of HasManyAssociation
| * | Preserve Array#take(n) behaviour of HasManyAssociationAkira Matsuda2015-02-281-0/+13
| | |
* | | Merge pull request #19077 from robin850/unknown-attribute-errorSean Griffin2015-03-021-1/+1
|\ \ \ | |/ / |/| | Move `UnknownAttributeError` to a more sane namespace
| * | Follow-up to #10776Robin Dupret2015-02-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The name `ActiveModel::AttributeAssignment::UnknownAttributeError` is too implementation specific so let's move the constant directly under the ActiveModel namespace. Also since this constant used to be under the ActiveRecord namespace, to make the upgrade path easier, let's avoid raising the former constant when we deal with this error on the Active Record side.
* | | Properly create through records when called with `where`Sean Griffin2015-02-261-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Various behaviors needed by associations (such as creating the through record) are lost when `where` is called, since we stop having a `CollectionProxy` and start having an `AssociationRelation` which does not contain this behavior. I *think* we should be able to rm `AssociationRelation`, but we have tests saying the changes required to do that would be bad (Without saying why. Of course. >_>) Fixes #19073.
* | | Merge pull request #17297 from ↵Rafael Mendonça França2015-02-251-0/+25
|\ \ \ | |/ / |/| | | | | | | | rebyn/fix/17161-remove-objs-from-has_many-updates-fields Add specs for adding-to/clear has_many collections’s behavior on `updated_at`
| * | Add specs for adding-to/clear has_many collections’s behavior on `updated_at`Tu Hoang2014-10-301-0/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are behaviors mentioned in #17161 that: 1. are not documented properly, and 2. don't have specs This commit addresses the spec absence. For has_many collections, 1. addition (<<) should update the associated object's updated_at (if any) 2. .clear, depending on options[:dependent], calls delete_all, destroy_all, or nullifies the associated object(s)' foreign key.
* | | Require `belongs_to` by default.Josef Šimánek2015-02-211-0/+50
| | | | | | | | | | | | Deprecate `required` option in favor of `optional` for belongs_to.
* | | Merge branch 'rm-take' into 4-1-stableRafael Mendonça França2015-02-201-1/+29
| | |
* | | Optimize none? and one? relation query methods to use LIMIT and COUNT.Eugene Gilburg2015-02-121-0/+76
| | | | | | | | | | | | | | | | | | | | | | | | Use SQL COUNT and LIMIT 1 queries for none? and one? methods if no block or limit is given, instead of loading the entire collection to memory. The any? and many? methods already follow this behavior. [Eugene Gilburg & Rafael Mendonça França]
* | | Merge branch 'master' into pr/18316Mingdong Luo2015-01-317-70/+45
|\ \ \ | | | | | | | | | | | | | | | | Conflicts: activerecord/CHANGELOG.md
| * | | Provide a better error message on :required associationHenrik Nygren2015-01-281-2/+22
| | | | | | | | | | | | | | | | Fixes #18696.
| * | | Use an `Attribute` object to represent a bind valueSean Griffin2015-01-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The column is primarily used for type casting, which we're trying to separate from the idea of a column. Since what we really need is the combination of a name, type, and value, let's use the object that we already have to represent that concept, rather than this tuple. No consumers of the bind values have been changed, only the producers (outside of tests which care too much about internals). This is *finally* possible since the bind values are now produced from a reasonable number of lcoations.
| * | | `WhereClause#predicates` does not need to be publicSean Griffin2015-01-273-13/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The only place it was accessed was in tests. Many of them have another way that they can test their behavior, that doesn't involve reaching into internals as far as they did. `AssociationScopeTest` is testing a situation where the where clause would have one bind param per predicate, so it can just ignore the predicates entirely. The where chain test was primarly duplicating the logic tested on `WhereClause` directly, so I instead just make sure it calls the appropriate method which is fully tested in isolation.
| * | | Test association was eager loaded, rather than reaching into internalsSean Griffin2015-01-261-2/+2
| | | |
| * | | Remove all references to `where_values` in testsSean Griffin2015-01-253-11/+11
| | | |
| * | | Extracted `ActiveRecord::AttributeAssignment` to ↵Bogdan Gusiev2015-01-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | `ActiveModel::AttributesAssignment` Allows to use it for any object as an includable module.
| * | | Merge pull request #18458 from brainopia/fix_after_commit_for_fixturesJeremy Kemper2015-01-201-1/+0
| |\ \ \ | | | | | | | | | | Support after_commit callbacks in transactional fixtures
| | * | | after_commit runs after transactions with non-joinable parentsbrainopia2015-01-161-1/+0
| | | |/ | | |/| | | | | | | | | | | | | | | | | after_commit callbacks run after committing a transaction whose parent is not `joinable?`: un-nested transactions, transactions within test cases, and transactions in `console --sandbox`.
| * / | tests, use `drop_table if_exists: true` in our test suite.Yves Senn2015-01-201-2/+2
| |/ /
| * | remove deprecated support to preload instance-dependent associaitons.Yves Senn2015-01-051-22/+9
| | | | | | | | | | | | Addresses https://github.com/rails/rails/commit/ed56e596a0467390011bc9d56d462539776adac1#commitcomment-9145960
| * | Remove deprecated automatic counter caches on `has_many :through`Rafael Mendonça França2015-01-041-26/+0
| | |
* | | Fix n+1 query problem when eager loading nil associations (fixes #18312)Sammy Larbi2015-01-031-0/+8
|/ /
* | Merge pull request #15309 from iantropov/issue_12698_build_throughRafael Mendonça França2015-01-021-1/+10
|\ \ | | | | | | | | | | | | | | | | | | | | | Add setting of FK for throgh associations while building Conflicts: activerecord/CHANGELOG.md activerecord/test/cases/associations/has_many_through_associations_test.rb
| * | Add setting of FK for throgh associations while buildingIvan Antropov2014-05-251-1/+10
| | |
* | | Remove support to activerecord-deprecated_findersRafael Mendonça França2015-01-021-2/+1
| | |
* | | Merge pull request #15746 from amccloud/auto-inverse_of-in-moduleRafael Mendonça França2015-01-021-0/+12
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | Fixed automatic inverse_of for models nested in module Conflicts: activerecord/CHANGELOG.md
| * | | Fixed automatic inverse_of for models nested in moduleAndrew McCloud2014-06-151-0/+12
| | | |
* | | | Fix warning: assigned but unused variable - postRyuta Kamizono2014-12-311-1/+1
| | | |
* | | | Fix error message when trying to create an associated recordRafael Mendonça França2014-12-301-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This error only happens when the foreign key is missing. Before this fix the following exception was being raised: NoMethodError: undefined method `val' for #<Arel::Nodes::BindParam:0x007fc64d19c218> Now the message is: ActiveRecord::UnknownAttributeError: unknown attribute 'foreign_key' for Model.
* | | | Share foreign_key_present? implementation in _has_ associationsbrainopia2014-12-312-35/+57
| | | |
* | | | `eager_load` preserves readonly flag for associationsTakashi Kokubun2014-12-301-1/+4
| | | |
* | | | Add foreign_type option for polymorphic has_one and has_many.Ulisses Almeida + Kassio Borges2014-12-082-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | To be possible to use a custom column name to save/read the polymorphic associated type in a has_many or has_one polymorphic association, now users can use the option :foreign_type to inform in what column the associated object type will be saved.
* | | | Merge pull request #17889 from mxie/mx-fix-nonexistent-typoSean Griffin2014-12-023-4/+4
|\ \ \ \ | | | | | | | | | | Fix "nonexistent" typo in tests
| * | | | Fix "nonexistent" typo in testsMelissa Xie2014-12-023-4/+4
| | | | |
* | | | | Require missing association in testSean Griffin2014-12-021-0/+1
|/ / / /
* | | | Pass symbol as an argument instead of a blockErik Michaels-Ober2014-11-297-20/+18
| | | |
* | | | Adds preloaded_records method to NullPreloaderThorsten Ball2014-11-281-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes a regression where preloading association throws an exception if one of the associations in the preloading hash doesn't exist for one record. Fixes #16070
* | | | Fix a bug where AR::RecordNotSaved loses error messagesYuki Nishijima2014-11-273-9/+28
| | | | | | | | | | | | | | | | | | | | | | | | Since 3e30c5d, it started ignoring the given error message. This commit changes the behavior of AR::RecordNotSaved#initialize so that it no longer loses the given error message.
* | | | Setting an association replaces records with the same id in memorySean Griffin2014-11-251-0/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The records weren't being replaced since equality in Active Record is defined in terms of `id` only. It is reasonable to expect that the references would be replaced in memory, even if no queries are actually executed. This change did not appear to affect any other parts of the code base. I chose not to execute callbacks since we're not actually modifying the association in a way that will be persisted. Fixes #17730
* | | | Fix includes on association with a scope containing joins along with conditionssiddharth@vinsol.com2014-11-211-0/+6
| | | | | | | | | | | | | | | | on the joined assoiciation
* | | | Merge pull request #17575 from shikshachauhan/make-habtm-consistentRafael Mendonça França2014-11-191-0/+10
|\ \ \ \ | | | | | | | | | | Allow class_name option in habtm to be consistent with other association...
| * | | | Allow habtm class_name option to be consistent with other associationsshiksha2014-11-131-0/+10
| | | | |
* | | | | Build fix when running in isolationArun Agrawal2014-11-147-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | `Computer` class needs to be require See #17217 for more details
* | | | | Merge pull request #11694 from ↵Rafael Mendonça França2014-11-101-0/+7
|\ \ \ \ \ | |/ / / / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Empact/association-bind-values-not-updated-on-save Fix that a collection proxy could be cached before the save of the owner, resulting in an invalid proxy lacking the owner’s id Conflicts: activerecord/CHANGELOG.md
| * | | | Fix that a collection proxy could be cached before the save of the owner, ↵Ben Woosley2014-10-031-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | resulting in an invalid proxy lacking the owner’s id. Absent this fix calls like: owner.association.update_all to behave unexpectedly because they try to act on association objects where owner_id is null. more evidence here: https://gist.github.com/Empact/5865555 ``` Active Record 3.2.13 -- create_table(:firms, {:force=>true}) -> 0.1371s -- create_table(:clients, {:force=>true}) -> 0.0005s 1 clients. 1 expected. 1 clients updated. 1 expected. ``` ``` Active Record 4.0.0 -- create_table(:firms, {:force=>true}) -> 0.1606s -- create_table(:clients, {:force=>true}) -> 0.0004s 1 clients. 1 expected. 0 clients updated. 1 expected. ```
* | | | | Ensure HABTM relationships produce valid class names (Fixes #17119)Sammy Larbi2014-11-091-1/+10
| | | | |
* | | | | default scopes should break the cache on singulur_association.alfa-jpn2014-11-081-0/+29
| | | | | | | | | | | | | | | | | | | | fixes #17495
* | | | | default scopes should break the cache on has_many.Aaron Patterson2014-11-071-0/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | if you specify a default scope on a model, it will break caching. We cannot predict what will happen inside the scope, so play it safe for now. fixes #17495