I do updates on lifted entities using Slick. This code updates the firstName of a Contact object:
def updateContact(id: Int, firstName: Option[String]): Unit = {
val q1 = for {
c <- Contacts
if c.id is id
} yield c.firstName
// Update value with same or new value
q1.update(firstName.getOrElse(q1.list().head))
}
The option here is already useful for updating the value in case it is a Some (although it would be nicer if the update only happened if there is a new value).
What I am looking for is a way to query the object by ID, then do all the updates in memory using getOrElse and then do an update on the whole object.
Else I have to run the above for each field of the object which works but you know, feels like a dirty hack.