[jOOQ/jOOQ#16510] Avoid PostgreSQL empty array cast when explicit cast

is given
This commit is contained in:
Lukas Eder 2024-03-25 19:41:49 +01:00
parent dc0fc32349
commit d6ab3d090d

View File

@ -58,6 +58,7 @@ import org.jooq.DataType;
import org.jooq.Field;
import org.jooq.QueryPart;
import org.jooq.Record;
import org.jooq.RenderContext.CastMode;
// ...
import org.jooq.SQLDialect;
// ...
@ -93,6 +94,11 @@ implements
return false;
}
@Override
public boolean generatesCast() {
return true;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
private static <T> DataType<T[]> type(Collection<? extends Field<T>> fields) {
if (fields == null || fields.isEmpty())
@ -126,7 +132,7 @@ implements
else
c.visit(K_INT).sql("[]");
},
() -> fields.fields.length == 0 && REQUIRES_CAST.contains(ctx.dialect())
() -> fields.fields.length == 0 && REQUIRES_CAST.contains(ctx.dialect()) && ctx.castMode() != CastMode.NEVER
);
break;