aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models/comment.rb
Commit message (Collapse)AuthorAgeFilesLines
* Revert "Merge pull request #14544 from jefflai2/named_scope_sti"Rafael Mendonça França2014-05-211-1/+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-201-0/+1
|\ | | | | | | | | | | | | Fixes Issue #13466. Conflicts: activerecord/CHANGELOG.md
| * Fixes Issue #13466.Jefferson Lai2014-04-231-0/+1
| | | | | | | | | | | | 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.
* | Merge pull request #15078 from nbudin/fix_merger_filter_binds_comparison_masterRafael Mendonça França2014-05-141-0/+8
|\ \ | | | | | | | | | | | | | | | | | | 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-141-0/+8
|/ / | | | | | | | | | | | | | | | | | | | | | | | | 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.
* / 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
* Fix scope chaining + STIJon Leighton2013-04-051-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | See #9869 and #9929. The problem arises from the following example: class Project < ActiveRecord::Base scope :completed, -> { where completed: true } end class MajorProject < Project end When calling: MajorProject.where(tasks_count: 10).completed This expands to: MajorProject.where(tasks_count: 10).scoping { MajorProject.completed } However the lambda for the `completed` scope is defined on Project. This means that when it is called, `self` is Project rather than MajorProject. So it expands to: MajorProject.where(tasks_count: 10).scoping { Project.where(completed: true) } Since the scoping was applied on MajorProject, and not Project, this fails to apply the tasks_count condition. The solution is to make scoping apply across STI classes. I am slightly concerned about the possible side-effects of this, but no tests fail and it seems ok. I guess we'll see.
* failing test for #9869Neeraj Singh2013-04-051-0/+1
|
* Goodbye there, very special rubbish!Akira Matsuda2013-01-241-6/+0
|
* Deprecate ActiveRecord::Base.scoped.Jon Leighton2012-07-271-3/+3
| | | | | | | It doesn't serve much purpose now that ActiveRecord::Base.all returns a Relation. The code is moved to active_record_deprecated_finders.
* find and replace deprecated keysJon Leighton2012-04-271-1/+1
|
* %s/find(:\(first\|last\|all\), \([^()]*\))/scoped(\2).\1/gcI amongst other ↵Jon Leighton2012-04-271-1/+1
| | | | things
* Adds test to check that circular preloading does not modify Model.unscoped ↵Benedikt Deicke2012-04-031-0/+2
| | | | (as described in #5667)
* Deprecate eager-evaluated scopes.Jon Leighton2012-03-211-8/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Don't use this: scope :red, where(color: 'red') default_scope where(color: 'red') Use this: scope :red, -> { where(color: 'red') } default_scope { where(color: 'red') } The former has numerous issues. It is a common newbie gotcha to do the following: scope :recent, where(published_at: Time.now - 2.weeks) Or a more subtle variant: scope :recent, -> { where(published_at: Time.now - 2.weeks) } scope :recent_red, recent.where(color: 'red') Eager scopes are also very complex to implement within Active Record, and there are still bugs. For example, the following does not do what you expect: scope :remove_conditions, except(:where) where(...).remove_conditions # => still has conditions
* Fix exception if old and new targets are both nil. Fixes #1471.Jon Leighton2011-07-121-1/+4
|
* Test added for namedscope target.Arun Agrawal2011-06-031-1/+2
|
* Revert "Deprecate defining scopes with a callable (lambda, proc, etc) via ↵Jon Leighton2011-04-171-4/+1
| | | | | | | | | | the scope class method. Just define a class method yourself instead." This reverts commit f0e198bfa1e3f9689e0cde1d194a44027fc90b3c. Conflicts: activerecord/test/models/post.rb
* Deprecate defining scopes with a callable (lambda, proc, etc) via the scope ↵Jon Leighton2011-04-121-1/+4
| | | | class method. Just define a class method yourself instead.
* Merge branch 'master' into nested_has_many_throughJon Leighton2011-03-041-0/+6
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: activerecord/CHANGELOG activerecord/lib/active_record/association_preload.rb activerecord/lib/active_record/associations.rb activerecord/lib/active_record/associations/class_methods/join_dependency.rb activerecord/lib/active_record/associations/class_methods/join_dependency/join_association.rb activerecord/lib/active_record/associations/has_many_association.rb activerecord/lib/active_record/associations/has_many_through_association.rb activerecord/lib/active_record/associations/has_one_association.rb activerecord/lib/active_record/associations/has_one_through_association.rb activerecord/lib/active_record/associations/through_association_scope.rb activerecord/lib/active_record/reflection.rb activerecord/test/cases/associations/has_many_through_associations_test.rb activerecord/test/cases/associations/has_one_through_associations_test.rb activerecord/test/cases/reflection_test.rb activerecord/test/cases/relations_test.rb activerecord/test/fixtures/memberships.yml activerecord/test/models/categorization.rb activerecord/test/models/category.rb activerecord/test/models/member.rb activerecord/test/models/reference.rb activerecord/test/models/tagging.rb
| * Propagate association extensions to scopes called on the association.Glenn Vanderburg2011-02-011-0/+1
| | | | | | | | Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
| * Let AssociationCollection#find use #scoped to do its finding. Note that I am ↵Jon Leighton2011-01-031-0/+5
| | | | | | | | removing test_polymorphic_has_many_going_through_join_model_with_disabled_include, since this specifies different behaviour for an association than for a regular scope. It seems reasonable to expect scopes and association proxies to behave in roughly the same way rather than having subtle differences.
| * Add some tests for functionality in JoinAssociation which already exists but ↵Jon Leighton2010-10-131-0/+3
| | | | | | | | was previously untested
* | Add support for nested through associations in JoinAssociation. Hence ↵Jon Leighton2010-10-091-0/+1
| | | | | | | | Foo.joins(:bar) will work for through associations. There is some duplicated code now, which will be refactored.
* | Refactoring JoinDependency and friends. This improves the code (IMO) ↵Jon Leighton2010-10-061-0/+3
|/ | | | including adding some explanatory comments, but more importantly structures it in such a way as to allow a JoinAssociation to produce an arbitrary number of actual joins, which will be necessary for nested has many through support. Also added 3 tests covering functionality which existed but was not previously covered.
* Properly cache association_collection#scopes calls having argumentsPratik Naik2010-06-041-0/+1
|
* Rename named_scope to scopePratik Naik2010-01-181-3/+3
|
* Prevent overwriting of table name in merging SQL conditions [#2949 ↵Tristan Dunn2009-08-101-1/+5
| | | | state:resolved]
* Merge the has_finder gem, renamed as 'named_scope'. Closes #11404 [nkallen]Rick Olson2008-03-241-0/+2
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9084 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Make sure that belongs_to counter decrements when assigning nil Closes ↵Michael Koziarski2008-01-261-2/+2
| | | | | | #10804 [jeanmartin] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8735 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* move assets and modelsJeremy Kemper2008-01-181-0/+23
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8657 5ecf4fe2-1ee6-0310-87b1-e25e094e27de