Scala's future inside yield
<p>I would like to find some object (Fight) in the DB and based on it's presence return this particular object or create a new object in DB and return the newly created object. I implemented the following function:</p>

<pre><code>def findOrCreateFight(firstBoxer: BoxersRow, secondBoxer: BoxersRow, eventDate: java.sql.Date): Future[FightsRow] = {
  for {
    fight &lt;- findByBoxersAndDate(firstBoxer, secondBoxer, eventDate)
  } yield {
    fight match {
      case Some(f) =&gt; f
      case None =&gt; createAndFindFight(firstBoxer, secondBoxer, eventDate)
    }
  }
}
</code></pre>

<p>findByBoxersAndDate function returns Future[Option[FightsRow]] object and createAndFindFight function returns Future[FightsRow]. Now the compiler shows an error in a line with createAndFindFight function:</p>

<blockquote>
  <p>type mismatch; found :
  scala.concurrent.Future[models.Tables.FightsRow] required:
  models.Tables.FightsRow</p>
</blockquote>

<p>OK, so I need to get the completed result of this Future in the 'case None'. I thought about onComplete function but it returns Unit, not a desired FightsRow object. Any suggestion how to fix my function to have a best scala-able effect? :)</p>

<p>Best Regards</p>