Open mdedetrich opened 5 years ago
I checked the quill codebase and realized there are no test cases for liftQueryScalar
so it seems like it always broken.
So an update, I have managed to further isolate the issue. Turns out the problem isn't with liftQueryScalar
but rather with this expression
def `Ex 8 and 9 contains2`(set: Set[Int]) =
quote {
query[Person].filter { p =>
if (liftQuery(set).isEmpty)
true
else
liftQuery(set).contains(p.age)
}
}
Specifically if (liftQuery(set).isEmpty)
is what is failing.
Any word on this? This is a pretty common pattern for optional filters-to-sets-of-values.
Version: (e.g.
3.4.1
) Module: (e.g.quill-jdbc-monix
) Database: (e.g.postgres
)Expected behavior
Lets assume that we are lifting at runtime a
List
of valuesT
which require a customEncoder
forT
Typical use case for this is when we have some filter, i.e.
Since this compiles, I expect it to work fine when
statusFilter
is a valid value. If I happen to be using the wrongliftQuery
/liftQueryScalar
/liftScalar
I expect a compile time error. It also errors when you use other real values apart fromNil
Actual behavior
This compiles fine, however at runtime if
statusFilter
isNil
I happen to getIn my case
enumeratum.EnumEntry
happens to be super ofStatus
(we are usingEnumeratum
).Steps to reproduce the behavior
https://scastie.scala-lang.org/A6DIDy0rQh62lTi4nfYAyQ
Workaround
EDIT: There doesn't seem to be a workaround that actually generates correct queries and works at runtime. You can get it to compile by also using
lift
orliftScalar
however you then get broken queries.@getquill/maintainers