We\'d like to run a patch/partial UPDATE
with Slick (3.0.0) so that we only modify some of the fields in a record. Exactly which fields will be updated exactly will
You already have answers as written by @pedrorijo91 and @thirstycow but i'll try to explain why this doesnt work.
I'm havent used slick 3 but im guessing its because the map function doesnt return a consistent type for it to run update against. As a thought experiment, if you cut your call at map what do you think the type will be?
val partialQuery:??? = people.filter(_.name === "M Odersky")
.map(p =>
(name, age) match {
case (Some(_), Some(_)) => (p.name, p.age)
case (Some(_), None) => (p.name)
case (None , Some(_)) => (p.age)
}
);
val fullQuery:??? = partialQuery.update {
(name, age) match {
case (Some(_), Some(_)) => (name.get, age.get)
case (Some(_), None) => (name.get)
case (None , Some(_)) => (age.get)
}
}
The matcher returns different "shapes" at compile time which im guessing will revert to Any type.