title: How can I properly select columns to return in Sequel after multiple JOINs?
body: <p>I have a query with multiple JOINs. </p>
  
  <p>At the moment I get a result with all the columns from all the tables. And some of the columns have identical names because that's how it's in my database. How can I select the columns to return <strong>and adjust their names in the result set</strong>?</p>
  
  <p>I've tried:</p>
  
  <pre><code>    result = MyModel1.join(:table2, id: :table2_id)
  
  
      if condition1
        result = result.join(.....).where(.....)
      end
  
  
      if condition2
        result = result.join(.....).where(.....)
      end
  
      # and so on....
  
  
      result
  </code></pre>
  
  <p>And if I'm doing this:</p>
  
  <pre><code>  result.select([Sequel[:model1][:column1], Sequel[:model2][:column2]])
  </code></pre>
  
  <p>I end up with this after I convert it to json:</p>
  
  <pre><code>  [{"row":["column1_value1","column1_value11"]},{"row":["column1_value2","column1_value22"]},{"row":["column1_value3","column1_value33"]}]
  </code></pre>
  
  <p>What's the "row"? How to get rid of it? How to add the names of the columns and change the structure of that json response so it looks proper?      </p>
  
  <p>I want something like this:</p>
  
  <pre><code>  [
      {"column1": "column1_value1", "column2" "column1_value11"},
      {"column1": "column1_value2", "column2" "column1_value22"},
      {"column1": "column1_value3", "column2" "column1_value33"}
    ]
  </code></pre>