Skip to content

Commit

Permalink
Merge pull request #1088 from typelevel/backport/1086
Browse files Browse the repository at this point in the history
Handle Postgres oids greater than Int.MaxValue
  • Loading branch information
mpilquist authored May 9, 2024
2 parents 65e2794 + 24d482c commit 3913d3a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion modules/core/shared/src/main/scala/util/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,10 @@ object Typer {
case class TypeInfo(oid: Int, name: String, arrayTypeOid: Option[Int], relOid: Option[Int])

implicit class ProtocolOps[F[_]: Functor](p: Protocol[F]) {
val oid: Codec[Int] = Codec.simple(_.toString, _.toInt.asRight, Type.oid)
//Note Postgres defines oids as *unsigned* Ints https://www.postgresql.org/docs/current/datatype-oid.html
//Since Scala currently lacks a built-in unsigned Int type, if the oid exceeds `Int.MaxValue`
//it will be converted to/from a negative Int by this Codec (only observed in CockroachDB)
val oid: Codec[Int] = Codec.simple(java.lang.Integer.toUnsignedLong(_).toString, _.toLong.toInt.asRight, Type.oid)

val typeInfoMap: F[Map[Int, TypeInfo]] = {

Expand Down

0 comments on commit 3913d3a

Please sign in to comment.