slick.slick_2.13.3.5.2.source-code.GetResult.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of slick_2.13 Show documentation
Show all versions of slick_2.13 Show documentation
Scala Language-Integrated Connection Kit
The newest version!
package slick.jdbc
import java.sql.{Date, Time, Timestamp}
import slick.SlickException
import slick.util.TupleSupport
/** Basic conversions for extracting values from PositionedResults. */
trait GetResult[+T] extends (PositionedResult => T) { self =>
override def andThen[A](g: T => A): GetResult[A] = new GetResult[A] { def apply(rs: PositionedResult): A = g(self.apply(rs)) }
}
/** GetResult for tuple types. */
class GetTupleResult[+T <: Product](val children: GetResult[_]*) extends GetResult[T] {
def apply(rs: PositionedResult) =
TupleSupport.buildTuple(children.iterator.map(_.apply(rs)).toIndexedSeq).asInstanceOf[T]
override def toString = "GetTupleResult<"+children.length+">"
}
object GetResult {
implicit object GetBigDecimal extends GetResult[BigDecimal] { def apply(rs: PositionedResult) = rs.nextBigDecimal() }
implicit object GetBoolean extends GetResult[Boolean] { def apply(rs: PositionedResult) = rs.nextBoolean() }
implicit object GetByte extends GetResult[Byte] { def apply(rs: PositionedResult) = rs.nextByte() }
implicit object GetDate extends GetResult[Date] { def apply(rs: PositionedResult) = rs.nextDate() }
implicit object GetDouble extends GetResult[Double] { def apply(rs: PositionedResult) = rs.nextDouble() }
implicit object GetFloat extends GetResult[Float] { def apply(rs: PositionedResult) = rs.nextFloat() }
implicit object GetInt extends GetResult[Int] { def apply(rs: PositionedResult) = rs.nextInt() }
implicit object GetLong extends GetResult[Long] { def apply(rs: PositionedResult) = rs.nextLong() }
implicit object GetShort extends GetResult[Short] { def apply(rs: PositionedResult) = rs.nextShort() }
implicit object GetString extends GetResult[String] { def apply(rs: PositionedResult) = rs.nextString() }
implicit object GetTime extends GetResult[Time] { def apply(rs: PositionedResult) = rs.nextTime() }
implicit object GetTimestamp extends GetResult[Timestamp] { def apply(rs: PositionedResult) = rs.nextTimestamp() }
implicit object GetBigDecimalOption extends GetResult[Option[BigDecimal]] { def apply(rs: PositionedResult) = rs.nextBigDecimalOption() }
implicit object GetBooleanOption extends GetResult[Option[Boolean]] { def apply(rs: PositionedResult) = rs.nextBooleanOption() }
implicit object GetByteOption extends GetResult[Option[Byte]] { def apply(rs: PositionedResult) = rs.nextByteOption() }
implicit object GetDateOption extends GetResult[Option[Date]] { def apply(rs: PositionedResult) = rs.nextDateOption() }
implicit object GetDoubleOption extends GetResult[Option[Double]] { def apply(rs: PositionedResult) = rs.nextDoubleOption() }
implicit object GetFloatOption extends GetResult[Option[Float]] { def apply(rs: PositionedResult) = rs.nextFloatOption() }
implicit object GetIntOption extends GetResult[Option[Int]] { def apply(rs: PositionedResult) = rs.nextIntOption() }
implicit object GetLongOption extends GetResult[Option[Long]] { def apply(rs: PositionedResult) = rs.nextLongOption() }
implicit object GetShortOption extends GetResult[Option[Short]] { def apply(rs: PositionedResult) = rs.nextShortOption() }
implicit object GetStringOption extends GetResult[Option[String]] { def apply(rs: PositionedResult) = rs.nextStringOption() }
implicit object GetTimeOption extends GetResult[Option[Time]] { def apply(rs: PositionedResult) = rs.nextTimeOption() }
implicit object GetTimestampOption extends GetResult[Option[Timestamp]] { def apply(rs: PositionedResult) = rs.nextTimestampOption() }
@inline implicit def createGetTuple2[T1, T2](implicit c1: GetResult[T1], c2: GetResult[T2]): GetTupleResult[(T1, T2)] = new GetTupleResult[(T1, T2)](c1, c2)
@inline implicit def createGetTuple3[T1, T2, T3](implicit c1: GetResult[T1], c2: GetResult[T2], c3: GetResult[T3]): GetTupleResult[(T1, T2, T3)] = new GetTupleResult[(T1, T2, T3)](c1, c2, c3)
@inline implicit def createGetTuple4[T1, T2, T3, T4](implicit c1: GetResult[T1], c2: GetResult[T2], c3: GetResult[T3], c4: GetResult[T4]): GetTupleResult[(T1, T2, T3, T4)] = new GetTupleResult[(T1, T2, T3, T4)](c1, c2, c3, c4)
@inline implicit def createGetTuple5[T1, T2, T3, T4, T5](implicit c1: GetResult[T1], c2: GetResult[T2], c3: GetResult[T3], c4: GetResult[T4], c5: GetResult[T5]): GetTupleResult[(T1, T2, T3, T4, T5)] = new GetTupleResult[(T1, T2, T3, T4, T5)](c1, c2, c3, c4, c5)
@inline implicit def createGetTuple6[T1, T2, T3, T4, T5, T6](implicit c1: GetResult[T1], c2: GetResult[T2], c3: GetResult[T3], c4: GetResult[T4], c5: GetResult[T5], c6: GetResult[T6]): GetTupleResult[(T1, T2, T3, T4, T5, T6)] = new GetTupleResult[(T1, T2, T3, T4, T5, T6)](c1, c2, c3, c4, c5, c6)
@inline implicit def createGetTuple7[T1, T2, T3, T4, T5, T6, T7](implicit c1: GetResult[T1], c2: GetResult[T2], c3: GetResult[T3], c4: GetResult[T4], c5: GetResult[T5], c6: GetResult[T6], c7: GetResult[T7]): GetTupleResult[(T1, T2, T3, T4, T5, T6, T7)] = new GetTupleResult[(T1, T2, T3, T4, T5, T6, T7)](c1, c2, c3, c4, c5, c6, c7)
@inline implicit def createGetTuple8[T1, T2, T3, T4, T5, T6, T7, T8](implicit c1: GetResult[T1], c2: GetResult[T2], c3: GetResult[T3], c4: GetResult[T4], c5: GetResult[T5], c6: GetResult[T6], c7: GetResult[T7], c8: GetResult[T8]): GetTupleResult[(T1, T2, T3, T4, T5, T6, T7, T8)] = new GetTupleResult[(T1, T2, T3, T4, T5, T6, T7, T8)](c1, c2, c3, c4, c5, c6, c7, c8)
@inline implicit def createGetTuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9](implicit c1: GetResult[T1], c2: GetResult[T2], c3: GetResult[T3], c4: GetResult[T4], c5: GetResult[T5], c6: GetResult[T6], c7: GetResult[T7], c8: GetResult[T8], c9: GetResult[T9]): GetTupleResult[(T1, T2, T3, T4, T5, T6, T7, T8, T9)] = new GetTupleResult[(T1, T2, T3, T4, T5, T6, T7, T8, T9)](c1, c2, c3, c4, c5, c6, c7, c8, c9)
@inline implicit def createGetTuple10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10](implicit c1: GetResult[T1], c2: GetResult[T2], c3: GetResult[T3], c4: GetResult[T4], c5: GetResult[T5], c6: GetResult[T6], c7: GetResult[T7], c8: GetResult[T8], c9: GetResult[T9], c10: GetResult[T10]): GetTupleResult[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)] = new GetTupleResult[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)](c1, c2, c3, c4, c5, c6, c7, c8, c9, c10)
@inline implicit def createGetTuple11[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11](implicit c1: GetResult[T1], c2: GetResult[T2], c3: GetResult[T3], c4: GetResult[T4], c5: GetResult[T5], c6: GetResult[T6], c7: GetResult[T7], c8: GetResult[T8], c9: GetResult[T9], c10: GetResult[T10], c11: GetResult[T11]): GetTupleResult[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)] = new GetTupleResult[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)](c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11)
@inline implicit def createGetTuple12[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12](implicit c1: GetResult[T1], c2: GetResult[T2], c3: GetResult[T3], c4: GetResult[T4], c5: GetResult[T5], c6: GetResult[T6], c7: GetResult[T7], c8: GetResult[T8], c9: GetResult[T9], c10: GetResult[T10], c11: GetResult[T11], c12: GetResult[T12]): GetTupleResult[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)] = new GetTupleResult[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)](c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12)
@inline implicit def createGetTuple13[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13](implicit c1: GetResult[T1], c2: GetResult[T2], c3: GetResult[T3], c4: GetResult[T4], c5: GetResult[T5], c6: GetResult[T6], c7: GetResult[T7], c8: GetResult[T8], c9: GetResult[T9], c10: GetResult[T10], c11: GetResult[T11], c12: GetResult[T12], c13: GetResult[T13]): GetTupleResult[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13)] = new GetTupleResult[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13)](c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13)
@inline implicit def createGetTuple14[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14](implicit c1: GetResult[T1], c2: GetResult[T2], c3: GetResult[T3], c4: GetResult[T4], c5: GetResult[T5], c6: GetResult[T6], c7: GetResult[T7], c8: GetResult[T8], c9: GetResult[T9], c10: GetResult[T10], c11: GetResult[T11], c12: GetResult[T12], c13: GetResult[T13], c14: GetResult[T14]): GetTupleResult[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14)] = new GetTupleResult[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14)](c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14)
@inline implicit def createGetTuple15[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15](implicit c1: GetResult[T1], c2: GetResult[T2], c3: GetResult[T3], c4: GetResult[T4], c5: GetResult[T5], c6: GetResult[T6], c7: GetResult[T7], c8: GetResult[T8], c9: GetResult[T9], c10: GetResult[T10], c11: GetResult[T11], c12: GetResult[T12], c13: GetResult[T13], c14: GetResult[T14], c15: GetResult[T15]): GetTupleResult[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15)] = new GetTupleResult[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15)](c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15)
@inline implicit def createGetTuple16[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16](implicit c1: GetResult[T1], c2: GetResult[T2], c3: GetResult[T3], c4: GetResult[T4], c5: GetResult[T5], c6: GetResult[T6], c7: GetResult[T7], c8: GetResult[T8], c9: GetResult[T9], c10: GetResult[T10], c11: GetResult[T11], c12: GetResult[T12], c13: GetResult[T13], c14: GetResult[T14], c15: GetResult[T15], c16: GetResult[T16]): GetTupleResult[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16)] = new GetTupleResult[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16)](c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16)
@inline implicit def createGetTuple17[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17](implicit c1: GetResult[T1], c2: GetResult[T2], c3: GetResult[T3], c4: GetResult[T4], c5: GetResult[T5], c6: GetResult[T6], c7: GetResult[T7], c8: GetResult[T8], c9: GetResult[T9], c10: GetResult[T10], c11: GetResult[T11], c12: GetResult[T12], c13: GetResult[T13], c14: GetResult[T14], c15: GetResult[T15], c16: GetResult[T16], c17: GetResult[T17]): GetTupleResult[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17)] = new GetTupleResult[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17)](c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17)
@inline implicit def createGetTuple18[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18](implicit c1: GetResult[T1], c2: GetResult[T2], c3: GetResult[T3], c4: GetResult[T4], c5: GetResult[T5], c6: GetResult[T6], c7: GetResult[T7], c8: GetResult[T8], c9: GetResult[T9], c10: GetResult[T10], c11: GetResult[T11], c12: GetResult[T12], c13: GetResult[T13], c14: GetResult[T14], c15: GetResult[T15], c16: GetResult[T16], c17: GetResult[T17], c18: GetResult[T18]): GetTupleResult[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18)] = new GetTupleResult[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18)](c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18)
@inline implicit def createGetTuple19[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19](implicit c1: GetResult[T1], c2: GetResult[T2], c3: GetResult[T3], c4: GetResult[T4], c5: GetResult[T5], c6: GetResult[T6], c7: GetResult[T7], c8: GetResult[T8], c9: GetResult[T9], c10: GetResult[T10], c11: GetResult[T11], c12: GetResult[T12], c13: GetResult[T13], c14: GetResult[T14], c15: GetResult[T15], c16: GetResult[T16], c17: GetResult[T17], c18: GetResult[T18], c19: GetResult[T19]): GetTupleResult[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19)] = new GetTupleResult[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19)](c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19)
@inline implicit def createGetTuple20[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20](implicit c1: GetResult[T1], c2: GetResult[T2], c3: GetResult[T3], c4: GetResult[T4], c5: GetResult[T5], c6: GetResult[T6], c7: GetResult[T7], c8: GetResult[T8], c9: GetResult[T9], c10: GetResult[T10], c11: GetResult[T11], c12: GetResult[T12], c13: GetResult[T13], c14: GetResult[T14], c15: GetResult[T15], c16: GetResult[T16], c17: GetResult[T17], c18: GetResult[T18], c19: GetResult[T19], c20: GetResult[T20]): GetTupleResult[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20)] = new GetTupleResult[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20)](c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20)
@inline implicit def createGetTuple21[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21](implicit c1: GetResult[T1], c2: GetResult[T2], c3: GetResult[T3], c4: GetResult[T4], c5: GetResult[T5], c6: GetResult[T6], c7: GetResult[T7], c8: GetResult[T8], c9: GetResult[T9], c10: GetResult[T10], c11: GetResult[T11], c12: GetResult[T12], c13: GetResult[T13], c14: GetResult[T14], c15: GetResult[T15], c16: GetResult[T16], c17: GetResult[T17], c18: GetResult[T18], c19: GetResult[T19], c20: GetResult[T20], c21: GetResult[T21]): GetTupleResult[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21)] = new GetTupleResult[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21)](c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21)
@inline implicit def createGetTuple22[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22](implicit c1: GetResult[T1], c2: GetResult[T2], c3: GetResult[T3], c4: GetResult[T4], c5: GetResult[T5], c6: GetResult[T6], c7: GetResult[T7], c8: GetResult[T8], c9: GetResult[T9], c10: GetResult[T10], c11: GetResult[T11], c12: GetResult[T12], c13: GetResult[T13], c14: GetResult[T14], c15: GetResult[T15], c16: GetResult[T16], c17: GetResult[T17], c18: GetResult[T18], c19: GetResult[T19], c20: GetResult[T20], c21: GetResult[T21], c22: GetResult[T22]): GetTupleResult[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22)] = new GetTupleResult[(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22)](c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22)
implicit val GetUnit: GetResult[Unit] =
const(())
private[jdbc] object GetUpdateValue extends GetResult[Int] {
def apply(pr: PositionedResult): Int =
throw new SlickException("Update statements should not return a ResultSet")
}
def apply[T](implicit f: (PositionedResult => T)): GetResult[T] =
new GetResult[T] { def apply(rs: PositionedResult) = f(rs) }
def const[T](value: T): GetResult[T] =
apply(_ => value)
}