By default, Slick ignores values in columns with O.AutoInc
flag and lets database to fill that value during insert operation.
But sometimes i need to insert some specific value for auto incrementing column and Slick still ignores it. Is there any way to do that?
I know, i can make second table definition, without O.AutoInc
flag, but i'm looking for more elegant way to do it.
Update: Here is my case class and table definition:
case class Transaction (id: Long, timestamp: LocalDateTime, comment: Option[String])
class Transactions(tag: Tag) extends Table[Transaction](tag, "tx") {
implicit val localDTtoDate = MappedColumnType.base[LocalDateTime, Timestamp] (
l => Timestamp.valueOf(l),
d => d.toLocalDateTime
)
def id = column[Long]("id", O.PrimaryKey, O.AutoInc)
def timestamp = column[LocalDateTime]("ts")
def comment = column[Option[String]]("comment")
def * = (id, timestamp, comment) <> ((Transaction.apply _).tupled, Transaction.unapply)
}
*
-projection uses the ID column. Can you copy-paste your table definition? – jkinkead