-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Description
I've been playing around with slickless for the past few days. I'm particularly interested in getting extensible records to work with slick. A "record projection" would be a nice feature IMHO. Either by providing a RecordShape or by a MappedProjection.
class Users(tag: Tag) extends Table[Long :: String :: HNil](tag, "users") {
def id = column[Long]( "id", O.PrimaryKey, O.AutoInc )
def email = column[String]("email")
def * = ('id ->> id) :: ('email ->> email) :: HNil // support by RecordShape
// or
def * = (id :: email :: HNil).mappedWithRecord('id :: 'email :: HNil) // support by MappedProjection
}
As I just started my journey with shapeless, I could not get any of these two approaches to work. The closest I could come up with is a non working MappedProjection:
def mappedWithRecord[R <: HList : ClassTag, U <: HList, K <: HList](keys: K)
(implicit
shape: Shape[_ <: FlatShapeLevel, T, U, _]) =
new MappedProjection[R, U](
shape.toNode(hlist),
MappedScalaType.Mapper(
((f: HList) => f.zipWithKeys(keys)).asInstanceOf[Any => Any], // compiler error: could not find implicit value for parameter withKeys: shapeless.ops.hlist.ZipWithKeys[K,shapeless.HList]
((g: HList) => ???).asInstanceOf[Any => Any],
None
),
implicitly[ClassTag[R]]
)
}
So basically my two questions are:
- Would it even be possible to provide a
RecordShape? Unfortunately I could not even figure out where to start... - Why can't the compile find the implicit parameter
withKeysin the code above? What am I missing?
Metadata
Metadata
Assignees
Labels
No labels