[jOOQ/jOOQ#12747] Add runtime support for Informix UDTs

This commit is contained in:
Lukas Eder 2023-09-06 12:18:32 +02:00
parent b0d1be0d92
commit 209fd9c1eb
3 changed files with 41 additions and 2 deletions

View File

@ -37,6 +37,7 @@
*/
package org.jooq.impl;
// ...
import static org.jooq.impl.DefaultExecuteContext.localExecuteContext;
import static org.jooq.impl.Tools.fieldsArray;
import static org.jooq.impl.Tools.getMappedUDTName;
@ -52,6 +53,7 @@ import org.jooq.Field;
import org.jooq.QualifiedRecord;
import org.jooq.RecordQualifier;
import org.jooq.Row;
import org.jooq.SQLDialect;
import org.jooq.Scope;
/**
@ -110,10 +112,22 @@ abstract class AbstractQualifiedRecord<R extends QualifiedRecord<R>> extends Abs
@Override
public final String getSQLTypeName() throws SQLException {
ExecuteContext ctx = localExecuteContext();
// [#1693] This needs to return the fully qualified SQL type name, in
// case the connected user is not the owner of the UDT
return getMappedUDTName(localExecuteContext(), this);
String result = getMappedUDTName(ctx, this);
return result;
}
@SuppressWarnings({ "rawtypes", "unchecked" })

View File

@ -595,6 +595,18 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
if (QualifiedRecord.class.isAssignableFrom(type)) {
Class<QualifiedRecord<?>> t = (Class<QualifiedRecord<?>>) type;
result.put(getMappedUDTName(scope, t), t);
for (Field<?> field : getRecordQualifier(t).fields())
typeMap(field.getType(), scope, result);
}
@ -3883,7 +3895,14 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
}
static final class DefaultRecordBinding<U> extends InternalBinding<Record, U> {
static final Set<SQLDialect> REQUIRE_RECORD_CAST = SQLDialect.supportedBy(POSTGRES, YUGABYTEDB);
static final Set<SQLDialect> REQUIRE_RECORD_CAST = SQLDialect.supportedBy(POSTGRES, YUGABYTEDB);
DefaultRecordBinding(DataType<Record> dataType, Converter<Record, U> converter) {
super(dataType, converter);

View File

@ -53,6 +53,7 @@ import org.jooq.RecordQualifier;
import org.jooq.RenderContext;
import org.jooq.conf.ParamType;
import org.jooq.exception.SQLDialectNotSupportedException;
import org.jooq.impl.DefaultBinding.DefaultRecordBinding;
import org.jooq.impl.QOM.UNotYetImplemented;
/**
@ -115,6 +116,7 @@ final class QualifiedRecordConstant<R extends QualifiedRecord<R>> extends Abstra
// Due to lack of UDT support in the Postgres JDBC drivers, all UDT's
@ -145,6 +147,7 @@ final class QualifiedRecordConstant<R extends QualifiedRecord<R>> extends Abstra
switch (c.family()) {
case POSTGRES:
case YUGABYTEDB:
c.visit(K_ROW);
@ -172,6 +175,9 @@ final class QualifiedRecordConstant<R extends QualifiedRecord<R>> extends Abstra
// [#13174] Need to cast inline UDT ROW expressions to the UDT type
c -> c.visit(qualifier),
() -> REQUIRE_RECORD_CAST.contains(ctx.dialect())
);
}