title: Join three tables in Scala Slick or flatten nested tuples
body: <p>I need to do INNER JOIN three tables because of foreign key in the first one as follows:</p>
  <pre><code>CREATE TABLE &quot;product&quot; (
      &quot;id&quot; INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
      &quot;name&quot; VARCHAR NOT NULL,
      &quot;price&quot; FLOAT NOT NULL,
      &quot;categoryid&quot; INT NOT NULL,
      &quot;supplierid&quot; INT NOT NULL,
      FOREIGN KEY(categoryid) references category(id),
      FOREIGN KEY(supplierid) references supplier(id)
  );
  </code></pre>
  <p>In models I have method to handle list all:</p>
  <pre><code>def list(): Future[Seq[(Product, Category, Supplier)]] = db.run {
      productTable.join(categoryTable).on(_.categoryid === _.id).join(supplierTable).on(_._1.supplierid === _.id).result
    }
  </code></pre>
  <p>But this returns nested tuple instead of flat one: ((Product, Category), Supplier).
  Then how should I join those tables to get flat tuple or, if not possible to do that, how can I flatten this tuple?</p>
  <p>EDIT:</p>
  <p>Actually the only solution I found which works for me is manual use of map:</p>
  <pre><code>  def list(): Future[Seq[(Product, Category, Supplier)]] = db.run {
     productTable.join(categoryTable).on(_.categoryid === _.id).join(supplierTable).on(_._1.supplierid === _.id).result.map(a =&gt; Seq((a(1)._1._1,a(1)._1._2,a(1)._2)))
    }
  </code></pre>
  <p>Which looks and feels horrible. But only this works so far ...
  Any better ideas?</p>