aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2017-07-15 08:38:29 +0900
committerRyuta Kamizono <kamipo@gmail.com>2017-07-18 03:34:24 +0900
commit26ba655f36c20315390497a0963c23014cadeb91 (patch)
tree1cefae3a645371b9e17eeabe09af1506c2c48ed6 /activerecord/test/cases
parent8acca896cbaa01f6fc51969601888a440e83d53a (diff)
downloadrails-26ba655f36c20315390497a0963c23014cadeb91.tar.gz
rails-26ba655f36c20315390497a0963c23014cadeb91.tar.bz2
rails-26ba655f36c20315390497a0963c23014cadeb91.zip
Fix `where` with a custom table
Without this fix, SELECT clause doesn't use a custom table alias name: ``` % ARCONN=sqlite3 be ruby -w -Itest test/cases/relations_test.rb -n test_using_a_custom_table_affects_the_wheres Using sqlite3 Run options: -n test_using_a_custom_table_affects_the_wheres --seed 31818 E Error: RelationTest#test_using_a_custom_table_affects_the_wheres: ActiveRecord::StatementInvalid: SQLite3::SQLException: no such table: posts: SELECT "posts".* FROM "posts" "omg_posts" WHERE "omg_posts"."title" = ? LIMIT ? ```
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/relations_test.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb
index 6c35940c2e..ca15c95432 100644
--- a/activerecord/test/cases/relations_test.rb
+++ b/activerecord/test/cases/relations_test.rb
@@ -1915,11 +1915,11 @@ class RelationTest < ActiveRecord::TestCase
table_metadata = ActiveRecord::TableMetadata.new(Post, table_alias)
predicate_builder = ActiveRecord::PredicateBuilder.new(table_metadata)
- relation = ActiveRecord::Relation.new(Post, table_alias, predicate_builder)
- relation.where!(foo: "bar")
+ relation = ActiveRecord::Relation.create(Post, table_alias, predicate_builder)
- node = relation.arel.constraints.first.grep(Arel::Attributes::Attribute).first
- assert_equal table_alias, node.relation
+ post = posts(:welcome)
+
+ assert_equal post, relation.where!(title: post.title).take
end
test "#load" do