aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-05-05 13:23:15 -0700
committerJon Leighton <j@jonathanleighton.com>2011-05-05 13:23:15 -0700
commit030e1d06ca36e1ed235f8e34ac9bfb6906b12dce (patch)
treec52f53c5bcab6151728e0167602297c870f4617d /activerecord/test/cases/associations
parentf098c80947dee1b420cea4ca647d1ceb3e59eaea (diff)
parent9b7cd75db340b6d0c6f2ec342ae4d7a201e46e84 (diff)
downloadrails-030e1d06ca36e1ed235f8e34ac9bfb6906b12dce.tar.gz
rails-030e1d06ca36e1ed235f8e34ac9bfb6906b12dce.tar.bz2
rails-030e1d06ca36e1ed235f8e34ac9bfb6906b12dce.zip
Merge pull request #399 from ernie/join_conditions_on_join
Add association join conditions to JOIN clause, not WHERE
Diffstat (limited to 'activerecord/test/cases/associations')
-rw-r--r--activerecord/test/cases/associations/inner_join_association_test.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/inner_join_association_test.rb b/activerecord/test/cases/associations/inner_join_association_test.rb
index e2228228a3..124693f7c9 100644
--- a/activerecord/test/cases/associations/inner_join_association_test.rb
+++ b/activerecord/test/cases/associations/inner_join_association_test.rb
@@ -34,6 +34,17 @@ class InnerJoinAssociationTest < ActiveRecord::TestCase
assert_no_match(/JOIN/i, sql)
end
+ def test_join_conditions_added_to_join_clause
+ sql = Author.joins(:essays).to_sql
+ assert_match(/writer_type.*?=.*?Author/i, sql)
+ assert_no_match(/WHERE/i, sql)
+ end
+
+ def test_join_conditions_allow_nil_associations
+ authors = Author.includes(:essays).where(:essays => {:id => nil})
+ assert_equal 2, authors.count
+ end
+
def test_find_with_implicit_inner_joins_honors_readonly_without_select
authors = Author.joins(:posts).to_a
assert !authors.empty?, "expected authors to be non-empty"