aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2019-02-22 07:45:56 +0900
committerGitHub <noreply@github.com>2019-02-22 07:45:56 +0900
commit4c68fd2b3500c13a795b416cdc7a640a0b4f3b28 (patch)
tree8ceea09757bb44222397fcc799c5e3390a1c6060 /activerecord/lib
parent3b6602aa7a01fb415fce07ef32458b131e5762e1 (diff)
parent04a47898483dc851adad47a1849ec66070827fc6 (diff)
downloadrails-4c68fd2b3500c13a795b416cdc7a640a0b4f3b28.tar.gz
rails-4c68fd2b3500c13a795b416cdc7a640a0b4f3b28.tar.bz2
rails-4c68fd2b3500c13a795b416cdc7a640a0b4f3b28.zip
Merge pull request #35360 from kamipo/fix_select_and_pluck_with_from
Fix `pluck` and `select` with `from` if `from` has original table name
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/relation/query_methods.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb
index 5563dfb6c9..f69b85af66 100644
--- a/activerecord/lib/active_record/relation/query_methods.rb
+++ b/activerecord/lib/active_record/relation/query_methods.rb
@@ -1068,8 +1068,10 @@ module ActiveRecord
def arel_column(field)
field = klass.attribute_alias(field) if klass.attribute_alias?(field)
+ from = from_clause.name || from_clause.value
- if klass.columns_hash.key?(field) && !from_clause.value
+ if klass.columns_hash.key?(field) &&
+ (!from || from == table.name || from == connection.quote_table_name(table.name))
arel_attribute(field)
else
yield