I'm trying to parse some SQL and save it as PushMessage (which is a class, not a case class - don't know if that matters). Following the Anorm documentation I have
implicit val parser: RowParser[PushMessage] = Macro.namedParser[PushMessage]
val result = db.withConnection { implicit connection: Connection =>
SQL"select * from PUSH_MESSAGES where VENDOR_ID=$requestedVendorId;".as(parser.*)
}
However, I'm getting a problem as IntelliJ tells me that Macro.namedParser[PushMessage] returns an Any, and not a RowParser[PushMessage]. I tried removing the declaration type, but then I couldn't run the parser using the .as(parser.*)
syntax.
How do I get this to return a RowParser?
Thanks in advance,
I guess you are using an Anorm version before 2.5.1 (April 2016), when the macros have been updated to use whitebox context . In such case, your IDE cannot properly infer the return type.
Note that Anorm 2.5.2 has just been released .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.