val q4 = quote {
query[Teams]
.join(q3)
.on(...)
.groupBy {
case (teams, inner) => teams.id
}
.map {
case (id, q) => Output(id, q.size)
}
}
// this fails
val q5 = quote {
query[Teams]
.join(q4)
.on { case (teams, inner) => teams.id == inner.teamId }
}
Expected behavior
Produce a correct sql
Actual behavior
exception during macro expansion:
java.lang.IllegalStateException: A `groupBy` clause must be followed by `map`.
at io.getquill.util.Messages$.fail(Messages.scala:15)
at io.getquill.context.sql.SqlQuery$.flatten(SqlQuery.scala:143)
at io.getquill.context.sql.SqlQuery$.flatten(SqlQuery.scala:83)
at io.getquill.context.sql.SqlQuery$.apply(SqlQuery.scala:76)
Workaround
use implicit join syntax
val q5 = quote {
for {
team <- query[Teams]
inner <- q4
if team.id == inner.teamId
} yield (team, inner)
}
Module:
quill-sql
Failing - https://scastie.scala-lang.org/mentegy/ZLficzsLRBqdPkWDE6Sc8Q Working (with a workaround) - https://scastie.scala-lang.org/mentegy/p2lpqYJlRsCV68PqxhXAiQ
Expected behavior
Produce a correct sql
Actual behavior
Workaround
use implicit join syntax
@getquill/maintainers