title: autoInc with Postgres and Slick
body: <p>When changing from in memory database to Postgres I came across the autoInc problem with Slick and Postgres. Piecing together several sources I ended up with the following solution. This avoids providing Null to the Id column on insert and returns the inserted records id, but at the cost of repeating the fields for the table in 3 different places. Is there any way to improve this? particularly for the withoutId definition but also the insert itself requiring the fields to be listed.</p>
  
  <pre><code>case class Product(
    id: Option[Long], 
    name: String,
    description: String
  )
  
  object Products extends Table[Product]("products") {
    def id = column[Long]("id", O.PrimaryKey, O.AutoInc)
    def name = column[String]("name")
    def description = column[Int]("description")
    def * = id.? ~ name ~ description &lt;&gt; (Product, Product.unapply _) // Fields listed
    def withoutId = name ~ description returning id // Fields listed again minus id
  
    def insert(product: Product): Product = {
      val id = DB withSession {
        withoutId.insert(product.name, product.description) // Fields listed again
      }
      product.copy(id = Option(id))
    }
  }
  </code></pre>