aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2012-07-13 11:44:35 +0100
committerJon Leighton <j@jonathanleighton.com>2012-07-13 11:44:45 +0100
commit4b4a85515bbae4ec88547727a5f7f17bc5cefdce (patch)
tree9c5b17843900dfb10f2be9f496e5b75c10631944 /activerecord/test/cases
parent1420d4e42f75f3bb1a17ae81b463799ab9cb0596 (diff)
downloadrails-4b4a85515bbae4ec88547727a5f7f17bc5cefdce.tar.gz
rails-4b4a85515bbae4ec88547727a5f7f17bc5cefdce.tar.bz2
rails-4b4a85515bbae4ec88547727a5f7f17bc5cefdce.zip
support relations created with a table alias
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/relations_test.rb10
1 files changed, 10 insertions, 0 deletions
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