Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scala 3 support #11

Merged
merged 15 commits into from
May 25, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Dedupe retrieval of data from Table.ImplicitMetadata with `fromImpl…
…icitMetadata` method.
  • Loading branch information
mrdziuban committed May 25, 2024
commit 0f142b3f58c6f4b093579bc2c86c3e64231079c9
37 changes: 18 additions & 19 deletions scalasql/query/src-3/TableMacro.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 41,18 @@ object TableMacros {
}
).asExprOf[V[F]]

def fromImplicitMetadata[O](paramTpe: TypeRepr)(
f: [T[_[_]]] => Expr[Table.Metadata[T]] => Type[T] ?=> O
): O =
paramTpe match {
case AppliedType(tpeCtor, _) =>
tpeCtor.asType match {
case '[
type t[_[_]]; t] =>
f[t]('{ summonInline[Table.ImplicitMetadata[t]].value })
}
}

val queryables = '{ (dialect: DialectTypeMappers, n: Int) =>
{
given DialectTypeMappers = dialect
Expand All @@ -63,15 75,9 @@ object TableMacros {
${
Expr.ofList(constructorValueParams.map { param =>
if (isTypeParamType(param))
paramType(param) match {
case AppliedType(tpeCtor, _) =>
tpeCtor.asType match {
case '[
type t[_[_]]; t] =>
'{ summonInline[Table.ImplicitMetadata[t]].value.walkLabels0() }
}
}
else '{ Seq(${ Expr(param.name) }) }
fromImplicitMetadata(paramType(param))([T[_[_]]] => t => '{ $t.walkLabels0() })
else
'{ Seq(${ Expr(param.name) }) }
})
}.flatten
}
Expand Down Expand Up @@ -128,16 134,9 @@ object TableMacros {
${
constructV[Column]((param, _) => { case (paramTpe, _, _) =>
if (isTypeParamType(param))
paramTpe match {
case AppliedType(tpeCtor, _) =>
tpeCtor.asType match {
case '[
type t[_[_]]; t] =>
'{
summonInline[Table.ImplicitMetadata[t]].value.vExpr(tableRef, dialect)
}.asTerm
}
}
fromImplicitMetadata(paramTpe)(
[T[_[_]]] => t => '{ $t.vExpr(tableRef, dialect) }.asTerm
)
else
paramTpe.typeArgs.head.asType match {
case '[t] =>
Expand Down
Loading