X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/5bbd6abc7a32c6912db5f36f0af5a923ac4b7c79..b6e28fbe905737bd0ea5bda5f4fd74fd259c58b1:/services/api/app/controllers/application_controller.rb?ds=sidebyside diff --git a/services/api/app/controllers/application_controller.rb b/services/api/app/controllers/application_controller.rb index 4a1a7d46db..d3b5c6b147 100644 --- a/services/api/app/controllers/application_controller.rb +++ b/services/api/app/controllers/application_controller.rb @@ -203,7 +203,17 @@ class ApplicationController < ActionController::Base end end - @objects = @objects.select(@select.map { |s| "#{table_name}.#{ActiveRecord::Base.connection.quote_column_name s.to_s}" }.join ", ") if @select + if @select + # Map attribute names in @select to real column names, resolve + # those to fully-qualified SQL column names, and pass the + # resulting string to the select method. + api_column_map = model_class.attributes_required_columns + columns_list = @select. + flat_map { |attr| api_column_map[attr] }. + uniq. + map { |s| "#{table_name}.#{ActiveRecord::Base.connection.quote_column_name s}" } + @objects = @objects.select(columns_list.join(", ")) + end @objects = @objects.order(@orders.join ", ") if @orders.any? @objects = @objects.limit(@limit) @objects = @objects.offset(@offset)