Skip to content

Commit

Permalink
continue
Browse files Browse the repository at this point in the history
  • Loading branch information
deusaquilus committed Dec 22, 2021
1 parent 6783d56 commit 1cc7bbf
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,23 @@ import io.getquill.ast._

object ExpandJoin extends StatelessTransformer {

object ExcludedFromNesting {
def unapply(ast: Ast) =
ast match {
case _: Entity => true
case _: Infix => true
case _: FlatJoin => true
}
}

override def apply(e: Query): Query = {
e match {
// Need to nest any map/flatMap clauses found in the `query` slot of a FlatMap or
// Verifier will cause Found an `ON` table reference of a table that is not available when they are
// found in this position.
case fm: FlatMap =>
super.apply(fm) match {
case FlatMap(ent: Entity, alias, body) =>
FlatMap(ent, alias, body)
case fm @ FlatMap(ExcludedFromNesting(), _, _) => fm
case FlatMap(ent, alias, body) =>
FlatMap(Nested(ent), alias, body)
case other =>
Expand All @@ -23,9 +31,8 @@ object ExpandJoin extends StatelessTransformer {
case Join(typ, a, b, iA, iB, on) =>
val a1 =
apply(a) match {
case v: Entity => v
case v: Infix => v
case other => Nested(other)
case v @ ExcludedFromNesting() => v
case other => Nested(other)
}
val b1 = apply(b)
FlatMap(a1, iA, Map(FlatJoin(typ, b1, iB, on), iB, Tuple(List(iA, iB))))
Expand Down

0 comments on commit 1cc7bbf

Please sign in to comment.