title: Preload with Ecto with subquery and using a join from the main query
body: <p>I'm using Ecto to request data from the database, and I've used the following code to preload the <strong>cats</strong> filtered by <strong>price_discount</strong>.</p>
  
  <pre><code>Item
  |&gt; join(:inner, [i], c in Cat, c.food_category_id == i.id)
  |&gt; where([i, c], is_nil(c.price_discount))
  |&gt; preload([i, c],
    [
      cats: c,
      cats: :houses
    ])
  </code></pre>
  
  <p>This works great, but now I want to order Houses by id, so I was hopping this work:</p>
  
  <pre><code>Item
  |&gt; join(:inner, [i], c in Cat, c.food_category_id == i.id)
  |&gt; where([i, c], is_nil(c.price_discount))
  |&gt; preload([i, c],
    [
      cats: c,
      cats: [
        houses: from(h in Houses, order_by: h.id)
      ]
    ])
  </code></pre>
  
  <p>But it doesn't, this is the error:</p>
  
  <pre><code>from(h in Houses, order_by: h.id()) is not a valid preload expression. preload expects an atom, a list of atoms or a keyword list with more preloads as values. Use ^ on the outermost preload to interpolate a value
  </code></pre>
  
  <p>The only post to work is to just use one of the following:</p>
  
  <ul>
  <li>Use <code>cats: c</code> without the order</li>
  <li>Use <code>houses: from(h in Houses, order_by: h.id)</code></li>
  </ul>
  
  <p>The following works, using ^:</p>
  
  <pre><code>Item
  |&gt; join(:inner, [i], c in Cat, c.food_category_id == i.id)
  |&gt; where([i, c], is_nil(c.price_discount))
  |&gt; preload([i, c],
    ^[
      cats: [
        houses: from(h in Houses, order_by: h.id)
      ]
    ])
  </code></pre>
  
  <p>Is this a bug in Ecto ?</p>