Skip to content

Commit 286a621

Browse files
committed
Add OID to the NumericAbstractCodec SUPPORTED_TYPES
1 parent e37ce2c commit 286a621

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import static io.r2dbc.postgresql.type.PostgresqlObjectId.INT4;
3636
import static io.r2dbc.postgresql.type.PostgresqlObjectId.INT8;
3737
import static io.r2dbc.postgresql.type.PostgresqlObjectId.NUMERIC;
38+
import static io.r2dbc.postgresql.type.PostgresqlObjectId.OID;;
3839

3940
/**
4041
* Codec to decode all known numeric types.
@@ -43,7 +44,7 @@
4344
*/
4445
abstract class AbstractNumericCodec<T extends Number> extends AbstractCodec<T> {
4546

46-
private static final Set<PostgresqlObjectId> SUPPORTED_TYPES = EnumSet.of(INT2, INT4, INT8, FLOAT4, FLOAT8, NUMERIC);
47+
private static final Set<PostgresqlObjectId> SUPPORTED_TYPES = EnumSet.of(INT2, INT4, INT8, FLOAT4, FLOAT8, NUMERIC, OID);
4748

4849
/**
4950
* Creates a new {@link AbstractCodec}.
@@ -133,9 +134,14 @@ private Number decodeNumber(ByteBuf buffer, PostgresqlObjectId dataType, @Nullab
133134
return buffer.readDouble();
134135
}
135136
return Double.parseDouble(ByteBufUtils.decode(buffer));
137+
case OID:
138+
if (FORMAT_BINARY == format) {
139+
return buffer.readInt();
140+
}
141+
return Integer.parseInt(ByteBufUtils.decode(buffer));
142+
default:
143+
throw new UnsupportedOperationException(String.format("Cannot decode value for type %s, format %s", dataType, format));
136144
}
137-
138-
throw new UnsupportedOperationException(String.format("Cannot decode value for type %s, format %s", dataType, format));
139145
}
140146

141147
/**

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ void intPrimitive() {
193193
testCodec(Integer.class, 100, "INT2");
194194
testCodec(Integer.class, 100, "INT4");
195195
testCodec(Integer.class, 100, "INT8");
196+
testCodec(Integer.class, 100, "OID");
196197
testCodec(Integer.class, 100, "NUMERIC");
197198
testCodec(Integer.class, 100, "FLOAT4");
198199
testCodec(Integer.class, 100, "FLOAT8");
@@ -289,6 +290,7 @@ void longPrimitive() {
289290
testCodec(Long.class, 100L, "INT2");
290291
testCodec(Long.class, 100L, "INT4");
291292
testCodec(Long.class, 100L, "INT8");
293+
testCodec(Long.class, 100L, "OID");
292294
testCodec(Long.class, 100L, "NUMERIC");
293295
testCodec(Long.class, 100L, "FLOAT4");
294296
testCodec(Long.class, 100L, "FLOAT8");

0 commit comments

Comments
 (0)