-
Notifications
You must be signed in to change notification settings - Fork 348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
if (liftQuery(set).isEmpty) doesn't work #1557
Comments
I checked the quill codebase and realized there are no test cases for |
So an update, I have managed to further isolate the issue. Turns out the problem isn't with 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 |
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
The text was updated successfully, but these errors were encountered: