在 /slick/profile/BasicProfile.scala 中,
trait API extends CommonAPI with CommonImplicits {
implicit def repQueryActionExtensionMethods[U](rep: Rep[U]): QueryActionExtensionMethods[U, NoStream] =
createQueryActionExtensionMethods[U, NoStream](queryCompiler.run(rep.toNode).tree, ())
implicit def streamableQueryActionExtensionMethods[U, C[_]](q: Query[_,U, C]): StreamingQueryActionExtensionMethods[C[U], U] =
createStreamingQueryActionExtensionMethods[C[U], U](queryCompiler.run(q.toNode).tree, ())
implicit def runnableCompiledQueryActionExtensionMethods[RU](c: RunnableCompiled[_, RU]): QueryActionExtensionMethods[RU, NoStream] =
createQueryActionExtensionMethods[RU, NoStream](c.compiledQuery, c.param)
implicit def streamableCompiledQueryActionExtensionMethods[RU, EU](c: StreamableCompiled[_, RU, EU]): StreamingQueryActionExtensionMethods[RU, EU] =
createStreamingQueryActionExtensionMethods[RU, EU](c.compiledQuery, c.param)
// Applying a CompiledFunction always results in only a RunnableCompiled, not a StreamableCompiled, so we need this:
implicit def runnableStreamableCompiledQueryActionExtensionMethods[R, RU, EU, C[_]](c: RunnableCompiled[Query[R, EU, C], RU]): StreamingQueryActionExtensionMethods[RU, EU] =
createStreamingQueryActionExtensionMethods[RU, EU](c.compiledQuery, c.param)
// This only works on Scala 2.11 due to SI-3346:
implicit def recordQueryActionExtensionMethods[M, R](q: M)(implicit shape: Shape[_ <: FlatShapeLevel, M, R, _]): QueryActionExtensionMethods[R, NoStream] =
createQueryActionExtensionMethods[R, NoStream](queryCompiler.run(shape.toNode(q)).tree, ())
}
有一个方法叫做repQueryActionExtensionMethods
将Rep
(的超类Query
)转换成QueryActionExtensionMethods