简体   繁体   English

使用Anorm的SqlParser出现问题

[英]Trouble with SqlParser using Anorm

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). 我正在尝试解析一些SQL并将其另存为PushMessage(这是一个类,而不是case类-不知道这是否重要)。 Following the Anorm documentation I have 遵循Anorm文档之后

 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]. 但是,我遇到了一个问题,因为IntelliJ告诉我Macro.namedParser [PushMessage]返回Any,而不是RowParser [PushMessage]。 I tried removing the declaration type, but then I couldn't run the parser using the .as(parser.*) syntax. 我尝试删除声明类型,但随后无法使用.as(parser.*)语法运行解析器。

How do I get this to return a RowParser? 我如何获得此结果以返回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 . 我猜您正在使用2.5.1之前的Anorm版本(2016年4月),当时已将宏更新为使用whitebox context In such case, your IDE cannot properly infer the return type. 在这种情况下,您的IDE无法正确推断返回类型。

Note that Anorm 2.5.2 has just been released . 请注意, Anorm 2.5.2刚刚发布

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM