You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
caseclassPerson(name: String, residesIn: String)
caseclassCountry(id:Int, name: String)
quote {
for {
p <- query[Person]
c <- query[Country].leftJoin(_.name == ct.residesIn)
} yield (p, c)
}
This will work. However, as soon as you introduce something in front of the c <- query[Country]... after the p <- query[Person], for example:
quote {
for {
p <- query[Person]
p1 <- query[Person] if (p.name == p1.name) // introduce something in between p and c
c <- query[Country].leftJoin(_.name == p.residesIn)
} yield (p.name, c.map(_.name))
}
Will yield the following error:
Error:(64, 16) exception during macro expansion:
java.lang.IllegalArgumentException: requirement failed: Found an `ON` table reference of a table that is not available: Set(p). The `ON` condition can only use tables defined through explicit joins.
at scala.Predef$.require(Predef.scala:224)
at io.getquill.context.sql.idiom.VerifySqlQuery$$anonfun$io$getquill$context$sql$idiom$VerifySqlQuery$$loop$1$1.apply(VerifySqlQuery.scala:49)
at io.getquill.context.sql.idiom.VerifySqlQuery$$anonfun$io$getquill$context$sql$idiom$VerifySqlQuery$$loop$1$1.apply(VerifySqlQuery.scala:39)
at scala.collection.LinearSeqOptimized$class.foldLeft(LinearSeqOptimized.scala:124)
at scala.collection.immutable.List.foldLeft(List.scala:84)
at io.getquill.context.sql.idiom.VerifySqlQuery$.io$getquill$context$sql$idiom$VerifySqlQuery$$loop$1(VerifySqlQuery.scala:39)
at io.getquill.context.sql.idiom.VerifySqlQuery$.verifyFlatJoins(VerifySqlQuery.scala:56)
at io.getquill.context.sql.idiom.VerifySqlQuery$.verify(VerifySqlQuery.scala:61)
at io.getquill.context.sql.idiom.VerifySqlQuery$.io$getquill$context$sql$idiom$VerifySqlQuery$$verify(VerifySqlQuery.scala:31)
at io.getquill.context.sql.idiom.VerifySqlQuery$.apply(VerifySqlQuery.scala:27)
at io.getquill.context.sql.idiom.SqlIdiom$class.translate(SqlIdiom.scala:30)
at io.getquill.SQLServerDialect$.translate(SQLServerDialect.scala:37)
at io.getquill.context.ContextMacro$class.translateStatic(ContextMacro.scala:51)
at io.getquill.context.ContextMacro$class.translate(ContextMacro.scala:37)
at io.getquill.context.ContextMacro$class.expand(ContextMacro.scala:24)
at io.getquill.context.QueryMacro.expand(QueryMacro.scala:8)
at io.getquill.context.QueryMacro.expandQueryWithMeta(QueryMacro.scala:45)
at io.getquill.context.QueryMacro.expandQuery(QueryMacro.scala:20)
at io.getquill.context.QueryMacro.runQuery(QueryMacro.scala:12)
println(run(q))
I see this as addressed in #636. In loop inside verifyFlatJoins inside VerifySqlQuery.scala, isn't it supposed to be:
case (av, TableContext(_, alias)) => av ++Set(alias) // i.e. the ++ is addedcase (av, InfixContext(_, alias)) => av ++Set(alias)
case (av, QueryContext(_, alias)) => av ++Set(alias)
As far as I understand, the aliases are supposed to be accumulated...
Version: (e.g.
2.3.3
)Module: (e.g.
quill-sql
)Database: (e.g.
any
)Let's say you have a query that looks like this:
This will work. However, as soon as you introduce something in front of the
c <- query[Country]...
after thep <- query[Person]
, for example:Will yield the following error:
Scastie can be found here:
https://scastie.scala-lang.org/deusaquilus/dXxO5hyRRbuAf8Hgz5aghQ
Workaround
Re-arrange the query so that leftJoins only use variables immediately before.
@getquill/maintainers
Edit: More readable.
The text was updated successfully, but these errors were encountered: