[jOOQ/jOOQ#15207] A fix for a regression when both

<outputSchemaToDefault>true</outputSchemaToDefault> and
<defaultSchema>false</defaultSchema>

In this fix, we move the assumption of an EnumType being stored in the schema from an EnumType::getSchema check to an EnumType::getName check. The latter being null really means the enum isn't stored.
This commit is contained in:
Lukas Eder 2023-06-20 13:00:00 +02:00
parent 28dac4ecc7
commit 91fa53d6c5
4 changed files with 8 additions and 8 deletions

View File

@ -3869,7 +3869,7 @@ public class JavaGenerator extends AbstractGenerator {
out.println("}");
out.println();
out.println("sealed trait %s extends %s[[before= with ][%s]] {", className, EnumType.class, interfaces);
out.println("sealed trait %s extends %s[[before= with ][separator= with ][%s]] {", className, EnumType.class, interfaces);
if (noCatalog)
out.println("override def getCatalog: %s = null", Catalog.class);

View File

@ -2865,7 +2865,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
c -> pgRenderEnumCast(c, dataType.getType(), enumValue),
// Postgres needs explicit casting for enum (array) types
() -> REQUIRE_ENUM_CAST.contains(ctx.dialect()) && enumValue.getSchema() != null
() -> REQUIRE_ENUM_CAST.contains(ctx.dialect()) && enumValue.getName() != null
);
}
@ -2878,7 +2878,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
c -> pgRenderEnumCast(c, dataType.getType(), enumValue),
// Postgres needs explicit casting for enum (array) types
() -> REQUIRE_ENUM_CAST.contains(ctx.dialect()) && enumValue.getSchema() != null
() -> REQUIRE_ENUM_CAST.contains(ctx.dialect()) && enumValue.getName() != null
);
}
@ -2929,9 +2929,9 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
}
static final void pgRenderEnumCast(Context<?> ctx, Class<?> type, EnumType value) {
Schema schema = value.getSchema();
if (schema != null) {
schema = using(ctx.configuration()).map(schema);
if (value.getName() != null) {
Schema schema = using(ctx.configuration()).map(value.getSchema());
if (schema != null && TRUE.equals(ctx.configuration().settings().isRenderSchema())) {
ctx.visit(schema);
ctx.sql('.');

View File

@ -13096,7 +13096,7 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
+ " private ").append(className).append("(String literal) { this.literal = literal; }\n"
+ " @Override\n"
+ " public String getName() {\n"
+ " return getClass().getName();\n"
+ " return null;\n"
+ " }\n"
+ " @Override\n"
+ " public String getLiteral() {\n"

View File

@ -6047,7 +6047,7 @@ final class Tools {
}
static final boolean storedEnumType(DataType<EnumType> enumType) {
return enumConstants(enumType)[0].getSchema() != null;
return enumConstants(enumType)[0].getName() != null;
}
private static final EnumType[] enumConstants(DataType<? extends EnumType> type) {