aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models
Commit message (Collapse)AuthorAgeFilesLines
...
* | 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
| * | Fix how to compute class name on habtm namespaced.Kassio Borges2014-05-133-0/+8
| | | | | | | | | | | | | | | | | | Thank's for @laurocaetano for the help with tests. :smiley: Fixes #14709
* | | Merge pull request #15078 from nbudin/fix_merger_filter_binds_comparison_masterRafael Mendonça França2014-05-142-0/+17
|\ \ \ | |/ / |/| | | | | | | | | | | | | | Make filter_binds filter out symbols that are equal to strings Conflicts: activerecord/CHANGELOG.md
| * | Make filter_binds filter out symbols that are equal to stringsNat Budin2014-05-142-0/+17
|/ / | | | | | | | | | | | | | | | | | | | | | | | | ActiveRecord::Relation::Merger's filter_binds method does not filter out bind variables when one of the attribute nodes has a string name, but the other has a symbol name, even when those names are actually equal. This can result in there being more bind variables than placeholders in the generated SQL. This is particularly an issue for PostgreSQL, where this is treated as an error. This patch changes the filter_binds method to make it convert both attribute names to strings before comparing.
* | Fix broken proc syntax for 1.9.3Arthur Neves2014-05-091-1/+1
| |
* | test, regression test for has_many with instance dependent scope.Yves Senn2014-05-091-0/+2
| |
* | Fixed HABTM's CollectionAssociation sizeFred Wu2014-05-081-0/+2
| | | | | | | | | | 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.
* | Add support for module-level table_suffix in modelsJenner LaFave2014-05-051-0/+18
| | | | | | | | | | This makes table_name_suffix work the same as table_name_prefix when using namespaced models. Pretty much the same as 67d1cec.
* | Merge pull request #14978 from bogdan/relation-joinRafael Mendonça França2014-05-051-0/+4
|\ \ | | | | | | | | | [Regression 4.0 -> 4.1] Put back Relation#join method as a delegate to Array
| * | Put back Relation#join method as a delegate to ArrayBogdan Gusiev2014-05-051-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | This is a regression 4.0 -> 4.1 fix. In 4.1.0 Relation#join is delegated to Arel#SelectManager. In 4.0 series it is delegated to Array#join This patch puts back the behaviour of 4.0
* | | Get rid of unused method in AR Post test modelCarlos Antonio da Silva2014-05-051-4/+0
|/ /
* | Fixed custom validation context bug where childEric Chahin2014-05-012-0/+12
| | | | | | | | | | | | | | | | associations were not being saved. Fixes #13854. [Eric Chahin, Aaron Nelson, & Kevin Casey]
* | Merge branch 'master' into adequaterecordAaron Patterson2014-04-252-0/+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 ...
| * \ Merge pull request #14573 from habermann24/has_many_through_fixRafael Mendonça França2014-04-222-0/+6
| |\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | Properly handle scoping with has_many :through. Fixes #14537. Conflicts: activerecord/CHANGELOG.md activerecord/test/cases/associations/has_many_through_associations_test.rb
| | * | Properly handle scoping with has_many :through. Fixes #14537.Jan Habermann2014-04-032-0/+6
| | | |
* | | | Merge branch 'master' into adequaterecordAaron Patterson2014-04-201-1/+0
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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
| * | | Remove outdated commentRafael Mendonça França2014-04-141-1/+0
| | | |
* | | | Merge branch 'master' into adequaterecordAaron Patterson2014-04-143-0/+8
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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 ...