[jOOQ/jOOQ#15873] IllegalArgumentException when calling UpdatableRecord methods on tables with embedded domains that replace their underlying fields

This commit is contained in:
Lukas Eder 2023-11-28 11:05:20 +01:00
parent a64d56ee92
commit 6561668238
2 changed files with 61 additions and 0 deletions

View File

@ -65,6 +65,8 @@ import static org.jooq.impl.QOM.JoinHint.LOOP;
import static org.jooq.impl.QOM.JoinHint.MERGE;
import static org.jooq.impl.Tools.EMPTY_FIELD;
import static org.jooq.impl.Tools.EMPTY_NAME;
import static org.jooq.impl.Tools.EMPTY_TABLE_FIELD;
import static org.jooq.impl.Tools.anyMatch;
import static org.jooq.impl.Tools.map;
import static org.jooq.impl.Tools.traverseJoins;
import static org.jooq.impl.Tools.unwrap;
@ -73,7 +75,9 @@ import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.function.BiFunction;
import java.util.function.Function;
@ -525,6 +529,59 @@ implements
return null;
}
static final record PrimaryKeyWithEmbeddables<R extends Record>(UniqueKey<R> primaryKey) {}
transient PrimaryKeyWithEmbeddables<R> primaryKeyWithEmbeddables;
/**
* [#15873] [#15875] Embeddable keys are currently listing their embedded
* columns, which may have been replaced.
*/
@SuppressWarnings("unchecked")
final UniqueKey<R> getPrimaryKeyWithEmbeddables() {
if (primaryKeyWithEmbeddables == null) {
UniqueKey<R> uniqueKey = getPrimaryKey();
primaryKeyWithEmbeddables = new PrimaryKeyWithEmbeddables<>(uniqueKey);
}
return primaryKeyWithEmbeddables.primaryKey;
}
/**
* {@inheritDoc}
* <p>

View File

@ -329,6 +329,10 @@ public class DefaultDataType<T> extends AbstractDataTypeX<T> {
this(dialect, null, type, systemName(typeName), typeName, castTypeName, null, null, null, Nullability.DEFAULT, null);
}
DefaultDataType(SQLDialect dialect, Class<T> type, String typeName, Nullability nullability) {
this(dialect, null, type, systemName(typeName), typeName, typeName, null, null, null, nullability, null);
}
DefaultDataType(SQLDialect dialect, Class<T> type, Name qualifiedTypeName) {
this(dialect, null, type, qualifiedTypeName, null, null, null, null, null, Nullability.DEFAULT, null);
}