override def from()

in scalding-db/src/main/scala/com/twitter/scalding/db/macros/impl/JdbcFieldSetter.scala [38:56]


  override def from(
      c: Context
  )(fieldType: c.Type, idx: Int, container: c.TermName, fieldValue: c.Tree): Try[c.Tree] = Try {
    import c.universe._

    // jdbc Statement indexes are one-based, hence +1 here
    def simpleType(accessor: Tree) = q"""$accessor(${idx + 1}, $fieldValue)"""

    fieldType match {
      case tpe if tpe =:= typeOf[String]  => simpleType(q"$container.setString")
      case tpe if tpe =:= typeOf[Boolean] => simpleType(q"$container.setBoolean")
      case tpe if tpe =:= typeOf[Short]   => simpleType(q"$container.setShort")
      case tpe if tpe =:= typeOf[Int]     => simpleType(q"$container.setInt")
      case tpe if tpe =:= typeOf[Long]    => simpleType(q"$container.setLong")
      case tpe if tpe =:= typeOf[Float]   => simpleType(q"$container.setFloat")
      case tpe if tpe =:= typeOf[Double]  => simpleType(q"$container.setDouble")
      case _                              => sys.error(s"Unsupported primitive type $fieldType")
    }
  }