doobie.enum.autogeneratedkeys.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of doobie-core_2.10 Show documentation
Show all versions of doobie-core_2.10 Show documentation
Pure functional JDBC layer for Scala.
The newest version!
package doobie.enum
import doobie.util.invariant._
import java.sql.Statement._
import scalaz.Equal
import scalaz.std.anyVal.intInstance
object autogeneratedkeys {
/** @group Implementation */
sealed abstract class AutoGeneratedKeys(val toInt: Int)
/** @group Values */ case object ReturnGeneratedKeys extends AutoGeneratedKeys(RETURN_GENERATED_KEYS)
/** @group Values */ case object NoGeneratedKeys extends AutoGeneratedKeys(NO_GENERATED_KEYS)
/** @group Implementation */
object AutoGeneratedKeys {
def fromInt(n: Int): Option[AutoGeneratedKeys] =
Some(n) collect {
case ReturnGeneratedKeys.toInt => ReturnGeneratedKeys
case NoGeneratedKeys.toInt => NoGeneratedKeys
}
def unsafeFromInt(n: Int): AutoGeneratedKeys =
fromInt(n).getOrElse(throw InvalidOrdinal[AutoGeneratedKeys](n))
implicit val EqualAutoGeneratedKeys: Equal[AutoGeneratedKeys] =
Equal.equalBy(_.toInt)
}
}