aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models
Commit message (Collapse)AuthorAgeFilesLines
...
| * | Deprecate `ActiveModel::Errors` `add_on_empty` and `add_on_blank` methodsWojciech Wnętrzak2015-02-192-2/+2
| | | | | | | | | | | | without replacement.
* | | Add `ActiveRecord::Base.suppress`Michael Ryan2015-02-182-0/+6
|/ /
* | Add line endings to files which are missing themSean Griffin2015-02-176-6/+6
| | | | | | | | | | | | These files get modified whenever someone uses a tool like `sed`. Let's just get this over with in one commit so it'd not adding diff noise to something else.
* | Merge pull request #18512 from vipulnsward/18492-fixtures-with-stiAaron Patterson2015-01-312-3/+7
|\ \ | | | | | | Fix STI for fixtures from multi-files
| * | Fixes #18492Vipul A M2015-01-142-3/+7
| |/ | | | | | | | | | | | | - Add check for not deleting previously created fixtures, to overcome sti fixtures from multiple files - Added fixtures and fixtures test to verify the same - Fixed wrong fixtures duplicating data insertion in same table
* | Always perform validations on nested attribute associationsSean Griffin2015-01-301-1/+2
| | | | | | | | | | | | | | Collection associations would have already been validated, but singular associations were not. Fixes #18735.
* | Added #or to ActiveRecord::RelationMatthew Draper2015-01-281-0/+3
| | | | | | | | | | | | | | Post.where('id = 1').or(Post.where('id = 2')) # => SELECT * FROM posts WHERE (id = 1) OR (id = 2) [Matthew Draper & Gael Muller]
* | Don't redefine autosave association callbacks in nested attrsSean Griffin2015-01-282-0/+2
| | | | | | | | | | | | | | | | These callbacks will already have been defined when the association was built. The check against `reflection.autosave` happens at call time, not at define time, so simply modifying the reflection is sufficient. Fixes #18704
* | Improve consistency of counter caches updating in memorySean Griffin2015-01-261-1/+1
|/ | | | | | | | | | | | | | | | | When we made sure that the counter gets updated in memory, we only did it on the has many side. The has many side only does the update if the belongs to cannot. The belongs to side was updated to update the counter cache (if it is able). This means that we need to check if the belongs_to is able to update in memory on the has_many side. We also found an inconsistency where the reflection names were used to grab the association which should update the counter cache. Since reflection names are now strings, this means it was using a different instance than the one which would have the inverse instance set. Fixes #18689 [Sean Griffin & anthonynavarre]
* remove deprecated support to preload instance-dependent associaitons.Yves Senn2015-01-051-4/+0
| | | | Addresses https://github.com/rails/rails/commit/ed56e596a0467390011bc9d56d462539776adac1#commitcomment-9145960
* Add has_secure_token to Active Recordrobertomiranda2015-01-041-0/+4
| | | | | | Update SecureToken Docs Add Changelog entry for has_secure_token [ci skip]
* Deprecate `false` as the way to halt AR callbacksclaudiob2015-01-025-5/+5
| | | | | | | | | | Before this commit, returning `false` in an ActiveRecord `before_` callback such as `before_create` would halt the callback chain. After this commit, the behavior is deprecated: will still work until the next release of Rails but will also display a deprecation warning. The preferred way to halt a callback chain is to explicitly `throw(:abort)`.
* Merge pull request #15309 from iantropov/issue_12698_build_throughRafael Mendonça França2015-01-021-0/+2
|\ | | | | | | | | | | | | | | 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-0/+2
| |
* | Fix error message when trying to create an associated recordRafael Mendonça França2014-12-301-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* | AR specific length validator to respect `marked_for_destruction`.Yves Senn2014-12-301-0/+2
| | | | | | | | | | | | | | | | Closes #7247. Conflicts: activerecord/CHANGELOG.md activerecord/test/models/owner.rb
* | Remove all cases of manuallly wrapping `Arel::Nodes::Quoted`Sean Griffin2014-12-291-1/+1
| | | | | | | | | | | | | | | | | | | | This is no longer required now that we are injecting a type caster object into the Arel table, with the exception of uniqueness validations. Since it calls `ConnectionAdapter#type_cast`, the value has already been cast for the database. We don't want Arel to attempt to cast it further, so we need to continue wrapping it in a quoted node. This can potentially go away when this validator is refactored to make better use of `where` or the predicate builder.
* | Inform Arel we don't need additional type casting in testsSean Griffin2014-12-261-1/+1
| | | | | | | | | | | | | | Part of the larger refactoring to remove type casting from Arel. We can inform it that we already have the right type by wrapping the value in an `Arel::Nodes::Quoted`. This commit can be reverted when we have removed type casting from Arel in Rail 5.1
* | Don't perform statement caching for `find` when called from a scopeSean Griffin2014-12-221-0/+8
| | | | | | | | | | | | | | | | If there is a method defined such as `find_and_do_stuff(id)`, which then gets called on an association, we will perform statement caching and the parent ID will not change on subsequent calls. Fixes #18117
* | Add foreign_type option for polymorphic has_one and has_many.Ulisses Almeida + Kassio Borges2014-12-082-0/+6
| | | | | | | | | | | | | | 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.
* | Fix "nonexistent" typo in testsMelissa Xie2014-12-022-4/+4
| |
* | Pass symbol as an argument instead of a blockErik Michaels-Ober2014-11-293-4/+4
| |
* | Fix includes on association with a scope containing joins along with conditionssiddharth@vinsol.com2014-11-211-0/+1
| | | | | | | | on the joined assoiciation
* | Ensure HABTM relationships produce valid class names (Fixes #17119)Sammy Larbi2014-11-091-0/+2
| |
* | Use bind values for joined tables in where statementsSean Griffin2014-11-012-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In practical terms, this allows serialized columns and tz aware columns to be used in wheres that go through joins, where they previously would not behave correctly. Internally, this removes 1/3 of the cases where we rely on Arel to perform type casting for us. There were two non-obvious changes required for this. `update_all` on relation was merging its bind values with arel's in the wrong order. Additionally, through associations were assuming there would be no bind parameters in the preloader (presumably because the where would always be part of a join) [Melanie Gilman & Sean Griffin]
* | Raise an error for has_one associations which try to go :through a ↵Tu Hoang2014-10-151-0/+3
| | | | | | | | polymorphic association [#17263]
* | make sure cache is not used for collection assocations tooAaron Patterson2014-10-141-0/+1
| | | | | | | | follow up for #17052
* | Autosave callbacks shouldn't be `after_save`Agis-2014-10-131-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | 068f092ced8483e557725542dd919ab7c516e567 registered autosave callbacks as `after_save` callbacks. This caused the regression described in #17209. Autosave callbacks should be registered as `after_update` and `after_create` callbacks, just like before. This is a partial revert of 068f092ced8483e557725542dd919ab7c516e567. Fixes #17209.
* | Better regression test for Fixtures with fk as a symbolArthur Neves2014-09-221-1/+1
| |
* | Dynamically modified schema and association would not be correctly resetAkira Matsuda2014-09-062-0/+6
| | | | | | | | | | This fixes <"SQLite3::SQLException: no such column: legacy_things.person_id: SELECT \"legacy_things\".* FROM \"legacy_things\" WHERE \"legacy_things\".\"person_id\" = ?"> in OptimisticLockingTest#test_lock_destroy
* | Skip StatementCache for eager loaded associations (Fixes #16761)Sammy Larbi2014-09-042-0/+11
| | | | | | | | | | | | Eagerly loaded collection and singular associations are ignored by the StatementCache, which causes errors when the queries they generate reference columns that were not eagerly loaded. This commit skips the creation of the StatementCache as a fix for these scenarios.
* | Move association definition to the model fileAkira Matsuda2014-08-281-0/+1
| |
* | Only merge scopes with zero arity in has_many throughAgis-2014-08-202-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | with dynamic conditions. Fixes #16128 This bug was introduced in https://github.com/rails/rails/commit/c35e438620f2d56562251571377995359546393d so it's present from 4.1.2-rc1 and after. https://github.com/rails/rails/commit/c35e438620f2d56562251571377995359546393d merges any relation scopes passed as proc objects to the relation, but does *not* take into account the arity of the lambda. To reproduce: https://gist.github.com/Agis-/5f1f0d664d2cd08dfb9b
* | Fixes the `Relation#exists?` to work with polymorphic associations.Kassio Borges2014-08-181-0/+1
| | | | | | | | Fixes #15821.
* | Address ORA-00972: identifier is too long when tested with OracleYasuo Honda2014-07-142-2/+3
| | | | | | | | by using shorter attribute names.
* | Move writing unknown column exception to null attributeSean Griffin2014-06-261-0/+1
| | | | | | | | | | | | Making this change revealed several subtle bugs related to models with no primary key, and anonymous classes. These have been fixed as well, with regression tests added.
* | Deprecate automatic counter caches on has_many :throughSean Griffin2014-06-262-2/+2
| | | | | | | | | | | | | | | | | | | | | | Reliant on https://github.com/rails/rails/pull/15747 but pulled to a separate PR to reduce noise. `has_many :through` associations have the undocumented behavior of automatically detecting counter caches. However, the way in which it does so is inconsistent with counter caches everywhere else, and doesn't actually work consistently. As with normal `has_many` associations, the user should specify the counter cache on the `belongs_to`, if they'd like it updated.
* | Merge pull request #15772 from nbudin/sti_through_bugRafael Mendonça França2014-06-191-0/+7
|\ \ | | | | | | | | | Don't include inheritance column in the through_scope_attributes
| * | Don't include inheritance column in the through_scope_attributesNat Budin2014-06-171-1/+8
| | |
* | | Fix has_and_belongs_to_many in a namespaced model pointing to a non ↵Rafael Mendonça França2014-06-191-0/+1
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | namespaced model Now the following case will work fine class Tag < ActiveRecord::Base end class Publisher::Article < ActiveRecord::Base has_and_belongs_to_many :tags end Fixes #15761
* | Merge pull request #15343 from dontfidget/fix_polymorphic_automatic_inverse_ofRafael Mendonça França2014-06-132-0/+2
|\ \ | | | | | | prevent bad automatic inverse_of association
| * | use name specified by 'as' for automatic inverse association to avoid ↵Andrew S. Brown2014-06-102-0/+2
| |/ | | | | | | reflecting on wrong association
* / Fix regression on eager loading association based on SQL query ratherLauro Caetano2014-06-031-0/+12
|/ | | | | | than existing column. Fixes #15480.
* Revert "Merge pull request #14544 from jefflai2/named_scope_sti"Rafael Mendonça França2014-05-212-5/+0
| | | | | | | | | | | | This reverts commit 9a1abedcdeecd9464668695d4f9c1d55a2fd9332, reversing changes made to c72d6c91a7c0c2dc81cc857a1d6db496e84e0065. Conflicts: activerecord/CHANGELOG.md activerecord/test/models/comment.rb This change break integration with activerecord-deprecated_finders so I'm reverting until we find a way to make it work with this gem.
* build fix, use lambda syntax that ruby 1.9.3 understands.Yves Senn2014-05-211-1/+1
|
* Fix polymorphic eager load with foreign_key as String.Lauro Caetano2014-05-201-0/+3
| | | | | | | | | 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.
* Merge pull request #14544 from jefflai2/named_scope_stiRafael Mendonça França2014-05-202-0/+5
|\ | | | | | | | | | | | | Fixes Issue #13466. Conflicts: activerecord/CHANGELOG.md
| * Fixes Issue #13466.Jefferson Lai2014-04-232-0/+5
| | | | | | | | | | | | Changed the call to a scope block to be evaluated with instance_eval. The result is that ScopeRegistry can use the actual class instead of base_class when caching scopes so queries made by classes with a common ancestor won't leak scopes.
* | test, inline `DeveloperWithAggregate`, which is used by a single test.Yves Senn2014-05-191-6/+0
| |
* | Merge pull request #14871 from kassio/kb-fixes-namespaced-habtmRafael Mendonça França2014-05-143-0/+8
|\ \ | | | | | | | | | | | | | | | | | | Fix how to compute class name on habtm namespaced. Conflicts: activerecord/CHANGELOG.md