Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package org.jooq.impl;

import org.jooq.*;
import org.jooq.Record;
import org.jooq.RenderContext.CastMode;

import java.util.AbstractMap;
import java.util.AbstractSet;
import java.util.ArrayList;
Expand All @@ -15,7 +11,14 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import java.util.stream.IntStream;
import org.jooq.Context;
import org.jooq.DataType;
import org.jooq.Field;
import org.jooq.Record;
import org.jooq.RenderContext.CastMode;
import org.jooq.Select;
import org.jooq.Table;
import static org.jooq.impl.Keywords.K_VALUES;
import static org.jooq.impl.Tools.BooleanDataKey.DATA_STORE_ASSIGNMENT;

Expand Down Expand Up @@ -72,24 +75,13 @@ public static void toSQLUpsertSelect(Context<?> ctx, Select<?> select) {
}

public Select<Record> upsertSelect() {
Select<Record> select = null;

Map<Field<?>, List<Field<?>>> v = valuesFlattened();

for (int i = 0; i < rows; i++) {
int row = i;
Select<Record> iteration = DSL.select(Tools.map(
v.entrySet(), e -> patchDefault0(e.getValue().get(row), e.getKey())
));

if (select == null) {
select = iteration;
} else {
select = select.unionAll(iteration);
}
}

return select;
return IntStream.range(0, rows)
.mapToObj(row -> (Select<Record>) DSL.select(Tools.map(v.entrySet(),
e -> patchDefault0(e.getValue().get(row), e.getKey()))))
.reduce(Select::unionAll)
.orElse(null);
}

private void toSQL92Values(Context<?> ctx) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void accept(Context<?> ctx) {

Table<?> t = InlineDerivedTable.inlineDerivedTable(ctx, table(ctx));
if (t instanceof InlineDerivedTable<?> i) {
copy(
try (var copyUpsertReplaceQuery = copy(
d -> {
if (!d.upsertReplaceMaps.isEmpty()) {
Table<?> m = DSL.table(name("t"));
Expand All @@ -97,7 +97,9 @@ public void accept(Context<?> ctx) {
}
},
i.table
).accept0(ctx);
)) {
copyUpsertReplaceQuery.accept0(ctx);
}
} else {
accept0(ctx);
}
Expand Down