diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-05-05 13:23:15 -0700 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2011-05-05 13:23:15 -0700 |
commit | 030e1d06ca36e1ed235f8e34ac9bfb6906b12dce (patch) | |
tree | c52f53c5bcab6151728e0167602297c870f4617d /activerecord/test/cases/associations/inner_join_association_test.rb | |
parent | f098c80947dee1b420cea4ca647d1ceb3e59eaea (diff) | |
parent | 9b7cd75db340b6d0c6f2ec342ae4d7a201e46e84 (diff) | |
download | rails-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/inner_join_association_test.rb')
-rw-r--r-- | activerecord/test/cases/associations/inner_join_association_test.rb | 11 |
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" |