From 4b4a85515bbae4ec88547727a5f7f17bc5cefdce Mon Sep 17 00:00:00 2001 From: Jon Leighton Date: Fri, 13 Jul 2012 11:44:35 +0100 Subject: support relations created with a table alias --- activerecord/test/cases/relations_test.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'activerecord/test/cases') diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index 8713b8d5e4..c8da7ddd99 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -1332,4 +1332,14 @@ class RelationTest < ActiveRecord::TestCase assert_equal expected, relation.inspect end end + + test 'using a custom table affects the wheres' do + table_alias = Post.arel_table.alias('omg_posts') + + relation = ActiveRecord::Relation.new Post, table_alias + relation.where!(:foo => "bar") + + node = relation.arel.constraints.first.grep(Arel::Attributes::Attribute).first + assert_equal table_alias, node.relation + end end -- cgit v1.2.3