[jOOQ/jOOQ#17433] Cannot call Record.reset(Field),
Record.original(Field), Record.changed(Field), Record.touched(Field), Record.modified(Field) with embeddable field arguments
This commit is contained in:
parent
bcb49ec0e5
commit
834b42ffe3
@ -43,11 +43,13 @@ import static java.util.Collections.emptyList;
|
||||
import static org.jooq.ContextConverter.scoped;
|
||||
import static org.jooq.conf.SettingsTools.updatablePrimaryKeys;
|
||||
import static org.jooq.impl.Tools.EMPTY_FIELD;
|
||||
import static org.jooq.impl.Tools.anyMatch;
|
||||
import static org.jooq.impl.Tools.converterOrFail;
|
||||
import static org.jooq.impl.Tools.converterContext;
|
||||
import static org.jooq.impl.Tools.embeddedFields;
|
||||
import static org.jooq.impl.Tools.indexFail;
|
||||
import static org.jooq.impl.Tools.indexOrFail;
|
||||
import static org.jooq.impl.Tools.nonReplacingEmbeddable;
|
||||
import static org.jooq.impl.Tools.settings;
|
||||
|
||||
import java.io.Writer;
|
||||
@ -204,7 +206,7 @@ implements
|
||||
|
||||
if (index >= 0)
|
||||
return (T) get(index);
|
||||
else if (Tools.nonReplacingEmbeddable(field))
|
||||
else if (nonReplacingEmbeddable(field))
|
||||
return (T) Tools
|
||||
.newRecord(fetched, ((EmbeddableTableField<?, ?>) field).recordType)
|
||||
.operate(new TransferRecordState<>(embeddedFields(field)));
|
||||
@ -294,7 +296,7 @@ implements
|
||||
final <T> void set(Field<T> field, int index, T value) {
|
||||
if (index >= 0)
|
||||
set(index, field, value);
|
||||
else if (Tools.nonReplacingEmbeddable(field)) {
|
||||
else if (nonReplacingEmbeddable(field)) {
|
||||
Field<?>[] f = embeddedFields(field);
|
||||
Object[] v = value instanceof EmbeddableRecord e
|
||||
? e.intoArray()
|
||||
@ -411,7 +413,16 @@ implements
|
||||
|
||||
@Override
|
||||
public final <T> T original(Field<T> field) {
|
||||
return (T) original(indexOrFail(fields, field));
|
||||
int index = fields.indexOf(field);
|
||||
|
||||
if (index >= 0)
|
||||
return (T) original(index);
|
||||
else if (nonReplacingEmbeddable(field))
|
||||
return (T) Tools
|
||||
.newRecord(fetched, ((EmbeddableTableField<?, ?>) field).recordType)
|
||||
.operate(((AbstractRecord) original()).new TransferRecordState<>(embeddedFields(field)));
|
||||
else
|
||||
throw Tools.indexFail(fields, field);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -496,7 +507,14 @@ implements
|
||||
|
||||
@Override
|
||||
public final boolean touched(Field<?> field) {
|
||||
return touched(indexOrFail(fields, field));
|
||||
int index = fields.indexOf(field);
|
||||
|
||||
if (index >= 0)
|
||||
return touched(index);
|
||||
else if (nonReplacingEmbeddable(field))
|
||||
return anyMatch(embeddedFields(field), f -> touched(f));
|
||||
else
|
||||
throw Tools.indexFail(fields, field);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -526,7 +544,15 @@ implements
|
||||
|
||||
@Override
|
||||
public final void touched(Field<?> field, boolean c) {
|
||||
touched(indexOrFail(fields, field), c);
|
||||
int index = fields.indexOf(field);
|
||||
|
||||
if (index >= 0)
|
||||
touched(index, c);
|
||||
else if (nonReplacingEmbeddable(field))
|
||||
for (Field<?> f : embeddedFields(field))
|
||||
touched(f, c);
|
||||
else
|
||||
throw Tools.indexFail(fields, field);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -563,7 +589,14 @@ implements
|
||||
|
||||
@Override
|
||||
public final boolean modified(Field<?> field) {
|
||||
return modified(indexOrFail(fields, field));
|
||||
int index = fields.indexOf(field);
|
||||
|
||||
if (index >= 0)
|
||||
return modified(index);
|
||||
else if (nonReplacingEmbeddable(field))
|
||||
return anyMatch(embeddedFields(field), f -> modified(f));
|
||||
else
|
||||
throw Tools.indexFail(fields, field);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -591,7 +624,15 @@ implements
|
||||
|
||||
@Override
|
||||
public final void reset(Field<?> field) {
|
||||
reset(indexOrFail(fields, field));
|
||||
int index = fields.indexOf(field);
|
||||
|
||||
if (index >= 0)
|
||||
reset(index);
|
||||
else if (nonReplacingEmbeddable(field))
|
||||
for (Field<?> f : embeddedFields(field))
|
||||
reset(f);
|
||||
else
|
||||
throw Tools.indexFail(fields, field);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Loading…
Reference in New Issue
Block a user