[#2591] Result.intoGroups() and similar methods create key Records with
changed=true
This commit is contained in:
parent
09eb2de5f0
commit
2eb4fcd8f2
@ -67,9 +67,9 @@ import org.jooq.Field;
|
||||
import org.jooq.Record;
|
||||
import org.jooq.RecordHandler;
|
||||
import org.jooq.RecordMapper;
|
||||
import org.jooq.RecordType;
|
||||
import org.jooq.Result;
|
||||
import org.jooq.Row;
|
||||
import org.jooq.RecordType;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.exception.InvalidResultException;
|
||||
import org.jooq.tools.Convert;
|
||||
@ -800,10 +800,10 @@ class ResultImpl<R extends Record> implements Result<R>, AttachableInternal {
|
||||
for (R record : this) {
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
Record key = new RecordImpl(keys);
|
||||
RecordImpl key = new RecordImpl(keys);
|
||||
|
||||
for (Field<?> field : keys) {
|
||||
Utils.setValue(key, field, record, field);
|
||||
Utils.copyValue(key, field, record, field);
|
||||
}
|
||||
|
||||
if (map.put(key, record) != null) {
|
||||
@ -909,10 +909,10 @@ class ResultImpl<R extends Record> implements Result<R>, AttachableInternal {
|
||||
for (R record : this) {
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
Record key = new RecordImpl(keys);
|
||||
RecordImpl key = new RecordImpl(keys);
|
||||
|
||||
for (Field<?> field : keys) {
|
||||
Utils.setValue(key, field, record, field);
|
||||
Utils.copyValue(key, field, record, field);
|
||||
}
|
||||
|
||||
Result<R> result = map.get(key);
|
||||
@ -961,10 +961,10 @@ class ResultImpl<R extends Record> implements Result<R>, AttachableInternal {
|
||||
for (R record : this) {
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
Record key = new RecordImpl(keys);
|
||||
RecordImpl key = new RecordImpl(keys);
|
||||
|
||||
for (Field<?> field : keys) {
|
||||
Utils.setValue(key, field, record, field);
|
||||
Utils.copyValue(key, field, record, field);
|
||||
}
|
||||
|
||||
List<E> list = map.get(key);
|
||||
|
||||
@ -1171,6 +1171,19 @@ final class Utils {
|
||||
target.setValue(targetField, targetField.getDataType().convert(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* [#2591] Type-safely copy a value from one record to another, preserving flags.
|
||||
*/
|
||||
static final <T> void copyValue(AbstractRecord target, Field<T> targetField, Record source, Field<?> sourceField) {
|
||||
Value<T> value = new Value<T>(
|
||||
targetField.getDataType().convert(source.getValue(sourceField)),
|
||||
targetField.getDataType().convert(source.original(sourceField)),
|
||||
source.changed(sourceField)
|
||||
);
|
||||
|
||||
target.setValue(targetField, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Map a {@link Schema} according to the configured {@link org.jooq.SchemaMapping}
|
||||
*/
|
||||
|
||||
@ -51,8 +51,13 @@ class Value<T> implements Serializable {
|
||||
private boolean isChanged;
|
||||
|
||||
Value(T value) {
|
||||
this.original = value;
|
||||
this(value, value, false);
|
||||
}
|
||||
|
||||
Value(T value, T original, boolean isChanged) {
|
||||
this.value = value;
|
||||
this.original = original;
|
||||
this.isChanged = isChanged;
|
||||
}
|
||||
|
||||
final T getValue() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user