Skip to content

Commit

Permalink
Polishing.
Browse files Browse the repository at this point in the history
Fix OID decoding.

[#495]

Signed-off-by: Mark Paluch <mpaluch@vmware.com>
  • Loading branch information
mp911de committed Feb 17, 2022
1 parent 26e540e commit 323d57c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit 323d57c

Please sign in to comment.