Skip to content

Commit a3f28a0

Browse files
committed
Use PostgresObjectId in PostgresType on best effort basis to obtain the default Java type
[#378]
1 parent 8b6d8c5 commit a3f28a0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

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

+6-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import io.r2dbc.postgresql.util.Assert;
2121
import reactor.core.publisher.Flux;
2222
import reactor.core.publisher.Mono;
23+
import reactor.util.annotation.Nullable;
2324

2425
import java.util.Objects;
2526
import java.util.StringJoiner;
@@ -93,7 +94,6 @@ public Flux<PostgresType> lookupTypes(Iterable<String> typeNames) {
9394
.flatMap(it -> it.map((row, rowMetadata) -> {
9495
return new PostgresType(row.get("oid", Integer.class), row.get("typname", String.class), row.get("typcategory", String.class));
9596
}));
96-
9797
}
9898

9999
public static class PostgresType implements PostgresTypeIdentifier {
@@ -104,10 +104,14 @@ public static class PostgresType implements PostgresTypeIdentifier {
104104

105105
private final String category;
106106

107+
@Nullable
108+
private final PostgresqlObjectId objectId;
109+
107110
public PostgresType(int oid, String name, String category) {
108111
this.oid = oid;
109112
this.name = name;
110113
this.category = category;
114+
this.objectId = PostgresqlObjectId.isValid(oid) ? PostgresqlObjectId.valueOf(oid) : null;
111115
}
112116

113117
@Override
@@ -121,7 +125,7 @@ public int getOid() {
121125

122126
@Override
123127
public Class<?> getJavaType() {
124-
return Object.class;
128+
return this.objectId != null ? this.objectId.getJavaType() : Object.class;
125129
}
126130

127131
@Override

0 commit comments

Comments
 (0)