From 26ba655f36c20315390497a0963c23014cadeb91 Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Sat, 15 Jul 2017 08:38:29 +0900 Subject: 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 ? ``` --- activerecord/lib/active_record/relation/query_methods.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index 8c2d546aff..c26c176c7b 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -1048,7 +1048,7 @@ module ActiveRecord if select_values.any? arel.project(*arel_columns(select_values.uniq)) else - arel.project(@klass.arel_table[Arel.star]) + arel.project(table[Arel.star]) end end -- cgit v1.2.3