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
In theory, if all parts of the inline def are known to the compiler you should be able to generate different queries based on the value that is given at the compile time.
This fails, though:
importio.getquill._classMyContextextendsSqlMirrorContext(MirrorSqlDialect, Literal)
valctx=newMyContext()
importctx.*enumColIdx:caseIdx1, Idx2caseclassInventory(col1: Int, col2: Int) {
inlinedefforIdx(inlineidx: ColIdx):Int=inline idx matchcaseColIdx.Idx1=> col1
caseColIdx.Idx2=> col2
}
inlinedefqueryFor(inlineidx: ColIdx) =
println(ctx.run(quote {
query[Inventory].map(_.forIdx(idx))
}))
/**This results in:Found the following variables: List(Inventory_this) that seem to originate outside of a `quote {...}` or `run {...}`block. In the AST:querySchema("Inventory").map(x1 => Inventory_this.col1)Quotes and run blocks cannot use values outside their scope directly (with the exception of inline expressions in Scala 3).In order to use runtime values in a quotation, you need to lift them, so insteadof this `Inventory_this` do this: `lift(Inventory_this)`.Here is a more complete example:Instead of this: `def byName(n: String) = quote(query[Person].filter(_.name == n))` Do this: `def byName(n: String) = quote(query[Person].filter(_.name == lift(n)))`**/
queryFor(ColIdx.Idx1)
queryFor(ColIdx.Idx2)
Version:
4.6.0.2-SNAPSHOT
Module:
quill-sql
In theory, if all parts of the
inline def
are known to the compiler you should be able to generate different queries based on the value that is given at the compile time.This fails, though:
https://scastie.scala-lang.org/OGDGYy6MTgeDuYXbPHUxuQ
I am not sure if this is an inherent limitation or could be fixed.
It seems that we need to replace the
Inventory_this
tox1
when compiling.Workaround
@getquill/maintainers
The text was updated successfully, but these errors were encountered: