Getting autoincrement values with Slick library in Scala

前端 未结 4 560
醉酒成梦
醉酒成梦 2021-02-01 21:22

How do I get the auto-incremented values for records inserted with Slick? The following code prints 1111. I would have expected it to print 1234

import scala.sli         


        
4条回答
  •  无人共我
    2021-02-01 21:50

    For me, following source worked (Slick 3.0.2)

    class Track(tag: Tag)
       extends Table[(Int, String, String)](tag, "TRACK") {
       // This is the primary key column:
       def id: Rep[Int] = column[Int]("ID", O.PrimaryKey, O.AutoInc)
       def artist: Rep[String] = column[String]("ARTIST")
       def name: Rep[String] = column[String]("NAME")
    
       def * : ProvenShape[(Int, String, String)] =
         (id, artist, name)
    }
    

提交回复
热议问题