Skip to content

Commit 46f3ed1

Browse files
committed
Polishing.
Fix OID decoding. [#495] Signed-off-by: Mark Paluch <[email protected]>
1 parent 77fc54c commit 46f3ed1

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/main/java/io/r2dbc/postgresql/codec/NumericDecodeUtils.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,14 @@ public static Number decodeNumber(ByteBuf buffer, PostgresqlObjectId dataType, @
6666
return buffer.readInt();
6767
}
6868
return Integer.parseInt(ByteBufUtils.decode(buffer));
69-
case INT8:
70-
case INT8_ARRAY:
7169
case OID:
7270
case OID_ARRAY:
71+
if (FORMAT_BINARY == format) {
72+
return buffer.readUnsignedInt();
73+
}
74+
return Long.parseLong(ByteBufUtils.decode(buffer));
75+
case INT8:
76+
case INT8_ARRAY:
7377
if (FORMAT_BINARY == format) {
7478
return buffer.readLong();
7579
}

src/test/java/io/r2dbc/postgresql/AbstractCodecIntegrationTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ void intPrimitive() {
361361
testCodec(Integer.class, 100, "INT2", R2dbcType.SMALLINT);
362362
testCodec(Integer.class, 100, "INT4", R2dbcType.INTEGER);
363363
testCodec(Integer.class, 100, "INT8", R2dbcType.INTEGER);
364-
testCodec(Integer.class, 100, "OID");
364+
testCodec(Long.class, 2314556683L, Integer.class, (actual, expected) -> assertThat(actual).isEqualTo(-1980410613), "OID", "$1", null);
365365
testCodec(Integer.class, 100, "NUMERIC", R2dbcType.NUMERIC);
366366
testCodec(Integer.class, 100, "FLOAT4", R2dbcType.FLOAT);
367367
testCodec(Integer.class, 100, "FLOAT8", R2dbcType.DOUBLE);
@@ -460,7 +460,7 @@ void longPrimitive() {
460460
testCodec(Long.class, 100L, "INT2");
461461
testCodec(Long.class, 100L, "INT4");
462462
testCodec(Long.class, 100L, "INT8");
463-
testCodec(Long.class, 100L, "OID");
463+
testCodec(Long.class, 2314556683L, "OID");
464464
testCodec(Long.class, 100L, "NUMERIC");
465465
testCodec(Long.class, 100L, "FLOAT4");
466466
testCodec(Long.class, 100L, "FLOAT8");

0 commit comments

Comments
 (0)