title: Slick select row by id
body: <p>Selecting a single row by id should be a simple thing to do, yet I'm having a bit of trouble figuring out how to map this to my object. </p>
  
  <p>I found <a href="https://stackoverflow.com/questions/16461260/select-single-row-based-on-id-in-slick">this question</a> which is looking for the same thing but the answer given does not work for me.</p>
  
  <p>Currently I have this that is working, but it doesn't seem as elegant as it should be.</p>
  
  <pre><code>def getSingle(id: Long):Option[Category] = withSession{implicit session =&gt;
   (for{cat &lt;- Category if cat.id === id} yield cat ).list.headOption
   //remove the .list.headOption and the function will return a WrappingQuery
  }
  </code></pre>
  
  <p>I feel getting a list then taking <code>headOption</code> is just bulky and unnecessary. I must be missing something.</p>
  
  <p>If it helps, here is more of my Category code</p>
  
  <pre><code>case class Category(
    id: Long = 0L,
    name: String
  )
  object Category extends Table[Category]("categories"){
  
    def name = column[String]("name", O.NotNull)
    def id = column[Long]("id", O.PrimaryKey, O.AutoInc)
  
    def * = id ~ name &lt;&gt; (Category.apply _, Category.unapply _)
  
    ...
  }
  </code></pre>
  
  <p>Is there an easier way to just get an Option[T] from an ID using Slick?</p>
  
  <p><strong>Solution</strong> There was a driver issue. I couldn't use <code>.firstOption</code> but upgraded to mysql jdbc 5.1.25 and all is well!</p>