zio / zio-quill

Compile-time Language Integrated Queries for Scala
https://zio.dev/zio-quill
Apache License 2.0
2.15k stars 348 forks source link

Pattern matching of Option is not supported inside quotation #514

Open mmagyar opened 8 years ago

mmagyar commented 8 years ago

Version: 0.8.0 Module: quill-async

Pattern matching of Option (Some/None) is not supported inside a quotation, it will throw a compile time error of failed ast parsing.

example code:

quote {
    query[UserGroupJoin].withFilter { case (u) => u.userId == lift(user.id) }
      .leftJoin(query[AccessControlListGroup])
      .on((userGroup, acl) => userGroup.userGroup == acl.userGroup)
      .withFilter {
        case (u) => u._2 match {
          case Some(acl) => acl.resource == lift(resource.id) && acl.enabled
          case None => lift(!resource.blockByDefault)
        }
      }
  }

@getquill/maintainers

fwbrasil commented 7 years ago

solution should be generic to any pattern matching by translating it to sql case/when