Skip to content

Commit 13c86eb

Browse files
committed
Fix wrong Jsonb OID
1 parent d68b508 commit 13c86eb

2 files changed

Lines changed: 27 additions & 3 deletions

File tree

PgBulkInsert/src/main/java/de/bytefish/pgbulkinsert/pgsql/constants/ObjectIdentifier.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public class ObjectIdentifier {
5353
// region OID 100 - 199
5454

5555
// JSON
56-
public static int Jsonb = 114;
56+
public static int Json = 114;
5757

5858
// XML content
5959
public static int Xml = 115;
@@ -191,7 +191,12 @@ public class ObjectIdentifier {
191191

192192
public static int Record = 2249;
193193

194-
// endregion
194+
// endregion JSONB
195+
196+
public static final int Jsonb = 3802;
197+
198+
// regio Jsonb
199+
195200

196201
private static Map<DataType, Integer> mapping = buildLookupTable();
197202

PgBulkInsert/src/test/java/de/bytefish/pgbulkinsert/test/pgsql/handlers/ArrayTypesTest.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ private static class ArrayEntity {
3232
public List<Short> shortArray;
3333
public List<Integer> integerArray;
3434
public List<Boolean> booleanArray;
35+
public List<String> jsonbArray;
3536

3637
public List<String> getStringArray() {
3738
return stringArray;
@@ -43,6 +44,7 @@ public List<String> getStringArray() {
4344
public List<Short> getShortArray() { return shortArray; }
4445
public List<Integer> getIntegerArray() { return integerArray; }
4546
public List<Boolean> getBooleanArray() { return booleanArray; }
47+
public List<String> getJsonbArray() { return jsonbArray; }
4648
}
4749

4850

@@ -70,6 +72,7 @@ public ArrayEntityMapping() {
7072
mapShortArray("col_short_array", ArrayEntity::getShortArray);
7173
mapIntegerArray("col_integer_array", ArrayEntity::getIntegerArray);
7274
mapBooleanArray("col_boolean_array", ArrayEntity::getBooleanArray);
75+
mapJsonbArray("col_jsonb_array", ArrayEntity::getJsonbArray);
7376
}
7477
}
7578

@@ -93,6 +96,8 @@ public void saveAll_VarCharArray_Test() throws SQLException, UnknownHostExceptio
9396
testStringArray("col_varchar_array");
9497
}
9598

99+
100+
96101
@Test
97102
public void saveAll_TextArray_Test() throws SQLException, UnknownHostException {
98103

@@ -187,6 +192,19 @@ public void saveAll_BooleanArray_Test() throws SQLException {
187192
testArrayInternal("col_boolean_array", entity, entity.booleanArray);
188193
}
189194

195+
@Test
196+
public void saveAll_JsonbArray_Test() throws SQLException {
197+
198+
// Create the Entity to insert:
199+
ArrayEntity entity = new ArrayEntity();
200+
entity.jsonbArray = Arrays.asList(
201+
"{\"bar\": \"baz\", \"balance\": 7.77}",
202+
"{\"bar\": \"baz\", \"balance\": 8.88}"
203+
);
204+
205+
testArrayInternal("col_jsonb_array", entity, entity.jsonbArray);
206+
}
207+
190208
@SuppressWarnings("unchecked")
191209
private <T> void testArrayInternal(String columnLabel, ArrayEntity entity, List<T> samples) throws SQLException {
192210
Objects.requireNonNull(samples, "samples");
@@ -229,7 +247,8 @@ private boolean createTable() throws SQLException {
229247
" col_long_array int8[],\n" +
230248
" col_short_array int2[],\n" +
231249
" col_integer_array int4[],\n" +
232-
" col_boolean_array boolean[]\n" +
250+
" col_boolean_array boolean[],\n" +
251+
" col_jsonb_array jsonb[]\n" +
233252
" );";
234253

235254
Statement statement = connection.createStatement();

0 commit comments

Comments
 (0)