Suppose I have a table with a number of small columns, and a large (say BLOB) column:
case class Thing(id: Int, small1: String, small2: String, small3: String, large: String)
class ThingMapping(tag: Tag) extends Table[Thing](tag, "things") {
def id = column[Int]("id", O.PrimaryKey, O.NotNull, O.AutoInc)
def small1 = column[String]("small1")
def small2 = column[String]("small2")
def small3 = column[String]("small3")
def large = column[String]("large")
def * = (id, small1, small2, small3, large) <> (Thing.tupled, Thing.unapply)
}
Under some circumstances, I'd like to query the table for all the columns except the large
column. In others, I'd like to include it. I prefer to use case classes rather than tuples.
Is there good pattern in Slick for doing this?
Options I've considered:
- Having two mappings -- a "skinny" and "fat" mapping.
- Splitting out the large column into a separate table, then joining it in if required.