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
Filtering on an optional enum value should generate a query.
Actual behavior
There's a compilation error of "The Co-Product element was not a Case Class or Value Type. Value-level Co-Products are not supported. Please write a decoder for it's parent-type".
Doing myTableQuery.filter(_.myTableType == lift(filter)) will compile, but using an optional filter and doing myTableQuery.filter(mt => lift(maybeFilter).forall(mt.myTableType == _)) will not. For an optional string query it would generate something like Quill Query: SELECT mt.id, mt.name, mt.my_table_type FROM my_table mt WHERE ? IS NULL OR mt.name = ?, so I think it should be doing something similar for an enum.
Workaround
@getquill/maintainers
The text was updated successfully, but these errors were encountered:
Actually I think as a workaround I can change that to be something more like the SQL generated by the forall statements, e.g. rather than myTableQuery.filter(mt => lift(maybeFilter).forall(mt.myTableType == _)) I can do something like myTableQuery.filter(mt => lift(maybeFilter.orNull) == null || mt.myTableType == lift(maybeFilter.orNull)).
edit - Although I also need to handle the null case in the encoder if I do this, I think.
Version: 4.6.0.1
Module: quill-jdbc-zio
Database: Postgres
Expected behavior
Filtering on an optional enum value should generate a query.
Actual behavior
There's a compilation error of "The Co-Product element was not a Case Class or Value Type. Value-level Co-Products are not supported. Please write a decoder for it's parent-type".
Steps to reproduce the behavior
https://scastie.scala-lang.org/j5t5LHW6Rnef3DP2cgaBew
Doing
myTableQuery.filter(_.myTableType == lift(filter))
will compile, but using an optional filter and doingmyTableQuery.filter(mt => lift(maybeFilter).forall(mt.myTableType == _))
will not. For an optional string query it would generate something likeQuill Query: SELECT mt.id, mt.name, mt.my_table_type FROM my_table mt WHERE ? IS NULL OR mt.name = ?
, so I think it should be doing something similar for an enum.Workaround
@getquill/maintainers
The text was updated successfully, but these errors were encountered: