title: Rails 5 Active record query not showing left_outer_joins attributes
body: <p>I am trying to do a left outer join to get related attributes and then sort by the related attribute.</p>
  <p>My problem is the related attribute pfeature_id is not listed in the output.</p>
  <p>I can't find any writings on what I may be doing wrong here.</p>
  <p>The examples 1 and 2 below, the related <code>product_features.pfeature_id </code> doesn't show in the listing.</p>
  <p>In example 3 the raw sql is run within sqlite3 or mysql and pfeature_id is shown.</p>
  <p>One of the pages I referred to was: <a href="https://guides.rubyonrails.org/active_record_querying.html#left-outer-joins" rel="nofollow noreferrer">https://guides.rubyonrails.org/active_record_querying.html#left-outer-joins</a></p>
  <p>Can someone tell what I am doing wrong?</p>
  <pre><code>1.
  
  albe@vamp398:/srv/test/brails/brail484b51$ dc exec web bundle exec rails console
  Loading development environment (Rails 5.2.3)
  
  irb(main):002:0&gt;  b=Product.left_joins(:product_feature).select(&quot;products.id,
   products.name, product_features.pfeature_id&quot;).where(&quot;products.id&gt;8&quot;).take(2)
  
    Product Load (0.7ms)  SELECT  products.id, products.name, 
  product_features.pfeature_id FROM &quot;products&quot; LEFT OUTER JOIN &quot;product_features&quot; ON 
  &quot;product_features&quot;.&quot;product_id&quot; = &quot;products&quot;.&quot;id&quot; WHERE (products.id&gt;8) 
  LIMIT ?  [[&quot;LIMIT&quot;, 2]]
  
  =&gt; [#&lt;Product id: 9, name: &quot;redKnife&quot;&gt;, #&lt;Product id: 10, name: &quot;pf&quot;&gt;]
  
  </code></pre>
  <pre><code>2.
  
  class Product &lt; ApplicationRecord
    has_many :product_feature
    has_many :pfeature, through: :product_feature
    
    def self.pf
      # raw sql select using ...
      Product.find_by_sql \
      &lt;&lt;-SQL
        SELECT  products.id, products.name, product_features.pfeature_id FROM products LEFT OUTER JOIN 
          product_features ON product_features.product_id = products.id 
      SQL
    end
  end
  
  irb(main):005:0&gt; b=Product.pf.last(4)
          
  SELECT  products.id, products.name, product_features.pfeature_id FROM products
   LEFT OUTER JOIN product_features ON product_features.product_id = products.id
  
  =&gt; [#&lt;Product id: 8, name: &quot;11&quot;&gt;, #&lt;Product id: 9, name: &quot;redKnife&quot;&gt;, 
  #&lt;Product id: 10, name: &quot;pf&quot;&gt;, #&lt;Product id: 10, name: &quot;pf&quot;&gt;]
  
  </code></pre>
  <pre><code>3.
  
  Run this sql in sqlite3 or MySQL:
  
  SELECT  products.id, &quot;products&quot;.name, product_features.pfeature_id FROM
   &quot;products&quot; LEFT OUTER JOIN &quot;product_features&quot; ON 
  &quot;product_features&quot;.&quot;product_id&quot; = &quot;products&quot;.&quot;id&quot; 
  WHERE (products.id&gt;8) LIMIT 2
  
      id  name      pfeature_id
      9   redKnife  NULL
      10  pf        8
  </code></pre>
  <pre><code>Tables:
  
    create_table &quot;product_features&quot;, force: :cascade do |t|
      t.string &quot;name&quot;
      t.integer &quot;product_id&quot;
      t.integer &quot;pfeature_id&quot;
      ...
    end
  
    create_table &quot;products&quot;, force: :cascade do |t|
      t.string &quot;name&quot;
      ...
    end
  </code></pre>