diff --git a/src/main/java/io/r2dbc/postgresql/codec/NumericDecodeUtils.java b/src/main/java/io/r2dbc/postgresql/codec/NumericDecodeUtils.java index ed8d0169..cd04d68e 100755 --- a/src/main/java/io/r2dbc/postgresql/codec/NumericDecodeUtils.java +++ b/src/main/java/io/r2dbc/postgresql/codec/NumericDecodeUtils.java @@ -66,10 +66,14 @@ public static Number decodeNumber(ByteBuf buffer, PostgresqlObjectId dataType, @ return buffer.readInt(); } return Integer.parseInt(ByteBufUtils.decode(buffer)); - case INT8: - case INT8_ARRAY: case OID: case OID_ARRAY: + if (FORMAT_BINARY == format) { + return buffer.readUnsignedInt(); + } + return Long.parseLong(ByteBufUtils.decode(buffer)); + case INT8: + case INT8_ARRAY: if (FORMAT_BINARY == format) { return buffer.readLong(); } diff --git a/src/test/java/io/r2dbc/postgresql/AbstractCodecIntegrationTests.java b/src/test/java/io/r2dbc/postgresql/AbstractCodecIntegrationTests.java index 2b6531fe..ca695fa5 100644 --- a/src/test/java/io/r2dbc/postgresql/AbstractCodecIntegrationTests.java +++ b/src/test/java/io/r2dbc/postgresql/AbstractCodecIntegrationTests.java @@ -361,7 +361,7 @@ void intPrimitive() { testCodec(Integer.class, 100, "INT2", R2dbcType.SMALLINT); testCodec(Integer.class, 100, "INT4", R2dbcType.INTEGER); testCodec(Integer.class, 100, "INT8", R2dbcType.INTEGER); - testCodec(Integer.class, 100, "OID"); + testCodec(Long.class, 2314556683L, Integer.class, (actual, expected) -> assertThat(actual).isEqualTo(-1980410613), "OID", "$1", null); testCodec(Integer.class, 100, "NUMERIC", R2dbcType.NUMERIC); testCodec(Integer.class, 100, "FLOAT4", R2dbcType.FLOAT); testCodec(Integer.class, 100, "FLOAT8", R2dbcType.DOUBLE); @@ -460,7 +460,7 @@ void longPrimitive() { testCodec(Long.class, 100L, "INT2"); testCodec(Long.class, 100L, "INT4"); testCodec(Long.class, 100L, "INT8"); - testCodec(Long.class, 100L, "OID"); + testCodec(Long.class, 2314556683L, "OID"); testCodec(Long.class, 100L, "NUMERIC"); testCodec(Long.class, 100L, "FLOAT4"); testCodec(Long.class, 100L, "FLOAT8");