1

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,

1
  • Have you tried compiling directly? IntelliJ doesn't always play well with macros and might be telling you something is wrong when it isn't actually.. Commented Jul 22, 2016 at 20:41

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for that precision! It save me a lot of time!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.