Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle Postgres oids greater than Int.MaxValue #1086

Merged
merged 1 commit into from
May 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I accidentally directly pushed a slight revision of the parsing logic in e66ae4f.


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

Expand Down
Loading