Anorm parse float values

青春壹個敷衍的年華 提交于 2019-12-03 11:09:37

You can always create your own column parser base on the existing ones:

 implicit def rowToFloat: Column[Float] = Column.nonNull { (value, meta) =>
  val MetaDataItem(qualified, nullable, clazz) = meta
  value match {
    case d: Float => Right(d)
    case _ => Left(TypeDoesNotMatch("Cannot convert " + value + ":" + value.asInstanceOf[AnyRef].getClass + " to Float for column " + qualified))
  }
}

but it matches on the type of value returned by the JDBC driver which may not be correct (depends on the column definition).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!