MCPcopy Index your code
hub / github.com/jOOQ/jOOQ / patchRecord

Method patchRecord

jOOQ/src/main/java/org/jooq/impl/JSONReader.java:247–367  ·  view source on GitHub ↗
(
        DSLContext ctx,
        ConverterContext cc,
        boolean multiset,
        Fields result,
        List<Object> record
    )

Source from the content-addressed store, hash-verified

245 static final Pattern P_NON_STRING_PREFIX = Pattern.compile("^(?s:[\\[{\"0-9].*|true|false|null)$");
246
247 private static final List<Object> patchRecord(
248 DSLContext ctx,
249 ConverterContext cc,
250 boolean multiset,
251 Fields result,
252 List<Object> record
253 ) {
254 for (int i = 0; i < result.fields().length; i++) {
255 Field<?> field = result.field(i);
256 Object value = record.get(i);
257 DataType<?> t = field.getDataType();
258
259 // [#19606] String values need to be quoted
260 if (t.isJSON() && value instanceof String s) {
261
262
263
264
265
266
267
268
269
270
271 record.set(i, toJSONString(s));
272 }
273
274 // [#8829] LoaderImpl expects binary data to be encoded in base64,
275 // not according to org.jooq.tools.Convert
276 else if (t.isBinary() && value instanceof String s) {
277 if (multiset) {
278 Matcher m;
279
280 // [#12134] PostgreSQL encodes binary data as hex
281 // TODO [#13427] This doesn't work if bytea_output is set to escape
282 if (ENCODE_BINARY_AS_HEX.contains(ctx.dialect()))
283 if (s.startsWith("\\x"))
284 record.set(i, convertHexToBytes(s, 1, Integer.MAX_VALUE));
285 else
286 record.set(i, convertHexToBytes(s));
287
288 // [#12134] [#18955] MariaDB encodes binary data as text (?) but we
289 // encode it explicitly as base64 for MULTISET usage
290 // [#12134] [#18876] MySQL encodes binary data as prefixed base64
291 // - type15: VARBINARY
292 // - type16: BIT
293 // - type249: TINYBLOB
294 // - type250: MEDIUMBLOB and LONG VARBINARY
295 // - type251: LONGBLOB
296 // - type252: BLOB
297 // - type254: BINARY
298 else if (ctx.family().category() == SQLDialectCategory.MYSQL
299 && (m = P_MYSQL_BINARY_PREFIX.matcher(s)).matches())
300 record.set(i, Base64.getDecoder().decode(m.replaceFirst("$1")));
301 else
302 record.set(i, Base64.getDecoder().decode(s));
303 }
304 else

Callers 1

readMethod · 0.95

Calls 15

readMethod · 0.95
matcherMethod · 0.80
allMatchMethod · 0.80
operateMethod · 0.80
fieldsMethod · 0.65
fieldMethod · 0.65
getMethod · 0.65
getDataTypeMethod · 0.65
isJSONMethod · 0.65
setMethod · 0.65
isBinaryMethod · 0.65
containsMethod · 0.65

Tested by

no test coverage detected