From fbbb6c87fd5e8fcd913c0dbf518024edd7538072 Mon Sep 17 00:00:00 2001 From: Paul Nikitochkin Date: Sat, 24 Aug 2013 19:12:05 +0300 Subject: Collapse where constraints to one where constraint In order to remove duplication with joining arel where constraints with `AND`, all constraints on `build_arel` are collapsed into one head node: `Arel::Nodes::And` Closes: #11963 --- activerecord/test/models/author.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'activerecord/test/models') diff --git a/activerecord/test/models/author.rb b/activerecord/test/models/author.rb index feb828de31..5d20389331 100644 --- a/activerecord/test/models/author.rb +++ b/activerecord/test/models/author.rb @@ -31,6 +31,13 @@ class Author < ActiveRecord::Base has_many :thinking_posts, -> { where(:title => 'So I was thinking') }, :dependent => :delete_all, :class_name => 'Post' has_many :welcome_posts, -> { where(:title => 'Welcome to the weblog') }, :class_name => 'Post' + has_many :welcome_posts_with_comment, + -> { where(title: 'Welcome to the weblog').where('comments_count = ?', 1) }, + class_name: 'Post' + has_many :welcome_posts_with_comments, + -> { where(title: 'Welcome to the weblog').where(Post.arel_table[:comments_count].gt(0)) }, + class_name: 'Post' + has_many :comments_desc, -> { order('comments.id DESC') }, :through => :posts, :source => :comments has_many :limited_comments, -> { limit(1) }, :through => :posts, :source => :comments has_many :funky_comments, :through => :posts, :source => :comments -- cgit v1.2.3