Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
deusaquilus committed Nov 6, 2023
1 parent 0de50de commit e3b0bcb
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 16 deletions.
16 changes: 8 additions & 8 deletions quill-core/src/main/scala/io/getquill/quat/QuatMaking.scala
Original file line number Diff line number Diff line change
Expand Up @@ -253,14 +253,14 @@ trait QuatMakingBase extends MacroUtilUniverse {
}

def isPrimitive(tpe: Type): Boolean =
tpe <:< typeOf[String] ||
tpe <:< typeOf[Int] ||
tpe <:< typeOf[Short] ||
tpe <:< typeOf[Long] ||
tpe <:< typeOf[Boolean] ||
tpe <:< typeOf[Byte] ||
tpe <:< typeOf[Float] ||
tpe <:< typeOf[Double]
tpe <:< typeOf[String] ||
tpe <:< typeOf[Int] ||
tpe <:< typeOf[Short] ||
tpe <:< typeOf[Long] ||
tpe <:< typeOf[Boolean] ||
tpe <:< typeOf[Byte] ||
tpe <:< typeOf[Float] ||
tpe <:< typeOf[Double]

object DefiniteValue {
def unapply(tpe: Type): Option[Type] =
Expand Down
2 changes: 1 addition & 1 deletion quill-engine/src/main/scala/io/getquill/ast/Ast.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ sealed trait Ast {
object Ast {
object LeafQuat {
def unapply(ast: Ast): Option[Ast] =
if (!ast.quat.isInstanceOf[Quat.Product] && ast.isInstanceOf[Value])
if (!ast.quat.isInstanceOf[Quat.Product])
Some(ast)
else
None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,12 +317,13 @@ case class SheathLeafClauses(state: Option[String], traceConfig: TraceConfig)
(Join(t, a1m, b1m, iA, iB, on), SheathLeafClauses(None, traceConfig))
}

case Filter(ent, e, LeafQuat(body)) =>
// For filter clauses the body is always a quat:V so we check the ident to see if it's something that needs to be sheathed
case Filter(ent, LeafQuat(e: Ident), body) =>
val (ent1, s) = apply(ent)
val e1 = Ident(e.name, ent1.quat)
// For filter clauses we want to go from: Filter(M(ent,e,e.v),e == 123) to Filter(M(ent,e,CC(v->e.v)),e,e.v == 123)
// For filter clauses we want to go from: Filter(M(ent,e,e.v),x == 123) to Filter(M(ent,e,CC(v->e.v)),x,x.v == 123)
// the body should not be re-sheathed since a body of CC(v->e.v == 123) would make no sense since
// that's not even a boolean. Instead we just need to do e.v == 123.
// that's not even a boolean. Instead we just need to do x.v == 123.
val bodyC = elaborateSheath(body)(s.state, e, e1)
trace"Sheath Filter(qry) with $stateInfo in $qq becomes" andReturn {
(Filter(ent1, e1, bodyC), s)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import io.getquill.norm.{DisablePhase, OptionalPhase}
import io.getquill.{Literal, MirrorSqlDialect, SqlMirrorContext, TestEntities}
import io.getquill.norm.ConfigList._

class AggregationSpec extends Spec {
class AggregationSpec extends Spec { //
case class Person(id: Int, name: String, age: Int)
case class PersonOpt(name: Option[String], age: Int)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ object SqlIdiomTestSpec {
// System.setProperty("quill.trace.color", "true")
// System.setProperty("quill.trace.quat", "full")
// System.setProperty("quill.trace.types", "all")
// io.getquill.util.Messages.resetCache()
// io.getquill.util.Messages.resetCache() //

val q = quote {
for {
v1 <- qr1.map(x => x.i).distinct
v2 <- qr2.filter(_.i == v1)
} yield (v1, v2)
}.dynamic
ctx.run(q).string ==
"SELECT i._1, x1.s, x1.i, x1.l, x1.o FROM (SELECT DISTINCT i.i AS _1 FROM TestEntity i) AS i, TestEntity2 x1 WHERE x1.i = i._1"
println(ctx.run(q).string)
// "SELECT i._1, x1.s, x1.i, x1.l, x1.o FROM (SELECT DISTINCT i.i AS _1 FROM TestEntity i) AS i, TestEntity2 x1 WHERE x1.i = i._1"
}

}

0 comments on commit e3b0bcb

Please sign in to comment.