It’s up to you to set that in your query.
If you use Foo.find_by_sql(‘select id from foos’), you’re going to get just the IDs back. Each one will be wrapped in an otherwise-empty Foo object, with a parameter set for each of the columns you put in your select clause. If you used select.*, then yes, you will get all the columns back.
It’s important to note that you could do Foo.find_by_sql(‘select id from bars’) and you would get an array of Foo objects, each containing only the id of all of your Bars. It’s literally running just whatever you place in the query string, warts and all, and returning it wrapped in whatever the parent model was.
If you wanted it to be completely agnostic, you could run it as ApplicationModel.find_by_sql(…). So it’s up to you to put whatever you want to select in your SQL query. To get these raw values back out, you’ll want to use pluck on the result. Here’s a ridiculous example:
2.6.6 :008 > Title.find_by_sql(‘select id, name from people’).pluck(:id, :name)
Title Load (0.3ms) select id, name from people
=> [[1, “Barney Rubble”], [2, “Mr. Slate”], [3, “Fred Flintstone”]]
If you need to get same-name parameters from across your multi-join SQL, then just as if you were doing this long-hand in Sequel Pro, you would assign aliases to each of the attributes you wanted to find:
select titles.name as title, people.name as author from titles, people where titles.person_id = people.id
That’s going to return [title: “Rocks I Have Crushed”, author: “Fred Flintstone”] etc.