首页 文章

Scala / Play错误重载的方法值[元组]无法应用于

提问于
浏览
1

Scala / Play错误@Overloaded方法值[tuple]无法应用于:请参阅下面的代码

def getPropertyFromRequest(implicit request: Request[AnyContent]): (Property, Option[ObjectId], Option[ObjectId], Option[ObjectId]) = {
    val p =
      Form(tuple(
        "desc" -> text,
        "url" -> text,
        "image" -> text,
        "price" -> text,
        "sqft" -> text,
        "address2" -> text,
        "lotsize" -> text,
        "taxes" -> text,
        "status" -> optional(text),
        "maint" -> text,
        "address" -> text,
        "mls" -> text,
        "baths" -> text,
        "beds" -> text,
        "partial_baths" -> text,
        "propertyId" -> optional(text),
        "snoopId" -> optional(text),
        "year_built" -> text,
        "groupId" -> optional(text) //upon adding this, error show up
      )).bindFromRequest().fold(
          errors => {Logger.error(errors.toString())
            throw new Error("could not parse form")},
          success => success
      )

      val a = GeoCoder.create(p._11 + " " + p._6)
      val property = Property(url = p._2,
        description = p._1,
        image = p._3,
        price = parseAmount(p._4).toDouble,
        sqft = p._5,
        lotSize = p._7,
        taxes = parseAmount(p._8),
        status = PropertyStatus.ACTIVE,
        maintenance = parseAmount(p._10),
        mls = p._12,
        baths = try{p._13.toDouble}catch{case e => 0},
        beds = try{p._14.toInt}catch{case e=> 0},
        partialBaths = try{p._15.toInt}catch{case e => 0},
        address = a,
        yearBuilt = Some(p._18))

      ( property, p._16.map(new ObjectId(_)) ,p._17.map(new ObjectId(_)), p._19.map(new ObjectId(_)) )
  }

注意:此代码工作正常,但在元组列表中添加 groupID 时,会显示错误 . 根据我的研究,元组只有22max元素,但是这个元素多达19个,所以不确定是什么时候发生的 .

提前致谢

1 回答

  • 1

    Forms中的 tuple 方法仅重载最多18个元组 .

    我不知道为什么Play在18点停止,它似乎是22的仲裁 .

    有几个工作 . 为更大的arity元组编写自己的 tuple 方法,或者使用嵌套的映射器 .

相关问题