From 1cc7bbf2f36125a443e089919a8243e7d6d218f9 Mon Sep 17 00:00:00 2001 From: Alexander Ioffe Date: Wed, 22 Dec 2021 17:10:33 -0500 Subject: [PATCH] continue --- .../scala/io/getquill/sql/norm/ExpandJoin.scala | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/quill-sql-portable/src/main/scala/io/getquill/sql/norm/ExpandJoin.scala b/quill-sql-portable/src/main/scala/io/getquill/sql/norm/ExpandJoin.scala index 1ddeff154b..b19aa700c1 100644 --- a/quill-sql-portable/src/main/scala/io/getquill/sql/norm/ExpandJoin.scala +++ b/quill-sql-portable/src/main/scala/io/getquill/sql/norm/ExpandJoin.scala @@ -4,6 +4,15 @@ 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 @@ -11,8 +20,7 @@ object ExpandJoin extends StatelessTransformer { // 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 => @@ -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))))