(List<?> list)
| 79 | } |
| 80 | |
| 81 | final Result<R> read(List<?> list) throws SQLException { |
| 82 | Result<R> result = new ResultImpl<>(dsl.configuration(), row); |
| 83 | |
| 84 | for (Object o : list) |
| 85 | result.add(newRecord(true, dsl.configuration(), recordType, row).operate(r -> { |
| 86 | Object[] attributes = |
| 87 | o instanceof ResultSet rs |
| 88 | ? read(rs) |
| 89 | : o instanceof Struct s |
| 90 | ? s.getAttributes() |
| 91 | : o instanceof List<?> l |
| 92 | ? l.toArray() |
| 93 | : null; |
| 94 | |
| 95 | if (attributes != null) { |
| 96 | |
| 97 | // [#13400] Recurse for nested MULTISET or ROW types |
| 98 | for (int i = 0; i < attributes.length && i < row.size(); i++) { |
| 99 | DataType<?> t = row.field(i).getDataType(); |
| 100 | |
| 101 | // [#16839] t.getRow() is null for scalar arrays, e.g. ARRAY (SELECT 1) |
| 102 | if (t.isMultiset() || t.isArray() && t.getRow() != null) { |
| 103 | if (attributes[i] instanceof List<?> l) { |
| 104 | |
| 105 | // [#18175] We may have already recursed into a ResultSet that produces nested MULTISET |
| 106 | if (!(l instanceof Result)) |
| 107 | attributes[i] = new ListHandler(dsl, ctx, (AbstractRow<?>) t.getRow(), t.getRecordType()).read(l); |
| 108 | } |
| 109 | else if (attributes[i] instanceof Array a) |
| 110 | attributes[i] = new ListHandler(dsl, ctx, (AbstractRow<?>) t.getRow(), t.getRecordType()).read(asList((Object[]) a.getArray())); |
| 111 | |
| 112 | // [#18175] JSON or XML MULTISET content may be nested in a ROW expression. |
| 113 | else if (attributes[i] instanceof String s) |
| 114 | attributes[i] = readMultiset(s, t); |
| 115 | else if (attributes[i] instanceof byte[] b) |
| 116 | attributes[i] = readMultiset(new String(b), t); |
| 117 | } |
| 118 | else if (t.isRecord() && (attributes[i] instanceof Struct || attributes[i] instanceof ResultSet)) |
| 119 | attributes[i] = new ListHandler(dsl, ctx, (AbstractRow<?>) t.getRow(), t.getRecordType()).read(asList(attributes[i])).get(0); |
| 120 | } |
| 121 | |
| 122 | r.fromArray(attributes); |
| 123 | r.touched(false); |
| 124 | return r; |
| 125 | } |
| 126 | else |
| 127 | throw new UnsupportedOperationException("No support for reading value " + o); |
| 128 | })); |
| 129 | |
| 130 | return result; |
| 131 | } |
| 132 | |
| 133 | @SuppressWarnings("unchecked") |
| 134 | private final Object readMultiset(String s, DataType<?> t) { |
nothing calls this directly
no test coverage detected