-->

Anorm's Row object no longer exists in Play 2.

2019-03-02 16:58发布

问题:

After upgrading to Play 2.3.0 I get this compilation error on object Row

not found: value Row

I noticed the Row object no longer exists in play 2.3.0 (I've found only the Row trait). Looking at the documentation, pattern matching should be still supported in Play 2.3

http://www.playframework.com/documentation/2.3.x/ScalaAnorm

See "Using Pattern Matching" paragraph

Here's my code:

def findById(aId: Long) = {
  DB.withConnection { implicit conn =>
    SQL(byIdStmt).on("id" -> aId)().map {
      case Row(id:Integer, Some(userId:String), Some(description:String), 
               Some(solrCriteria:String), Some(solrCriteriaHash:String), 
               Some(hits:Integer), Some(lastPerformedUtc:java.sql.Timestamp), Some(notify:Boolean) ) => 
        new UserInquiry(id.toLong, userId, description, solrCriteria, solrCriteriaHash, 
           hits, lastPerformedUtc, notify)
    }.head 
  }    
 }

How to solve that?

回答1:

As said, this pattern matching is restored on Play master by https://github.com/playframework/playframework/pull/3049 .