title: Sequelize: joining table on a subquery
body: <p>I am trying to join a table on a subquery, but I don't know how to express it using Sequelize ORM. This is the raw SQL I want to run:</p>
  
  <pre><code>SELECT *
  FROM table_a a
  LEFT OUTER JOIN (SELECT * FROM table_b b WHERE col = VAL) ON a.id = b.id;
  </code></pre>
  
  <p>I tried </p>
  
  <pre><code>A.findAll({
      include: [
          {
              model: B,
              where: { col: val },
          }
      ]
  }).then(...);
  </code></pre>
  
  <p>but that doesn't get me the query I want. Instead it changes the <code>join</code> to an <code>INNER JOIN</code>, and joins on <code>col = VALUE</code> instead. Is there a way to do a join on the result of a subquery? I am using Postgres if it matters.</p>
  
  <p>Update: After making the following change, the resulting query now uses a LEFT OUTER JOIN as expected:</p>
  
  <pre><code>include: [
      {
          model: B,
          where: { col: val },
          required: false,
      }
  ]
  </code></pre>
  
  <p>However, it is still joining on col = VALUE, the generated query looks like:</p>
  
  <pre><code>SELECT * FROM table_a a 
  LEFT OUTER JOIN table_b b ON a.id = b.id AND b.col = VALUE;
  </code></pre>