From a0f55fa4b89e13786f4b679e7a21c41b6f1ede56 Mon Sep 17 00:00:00 2001 From: lukaseder Date: Tue, 7 Jun 2016 23:05:40 +0300 Subject: [PATCH] [#5334] Nested record generated when TABLE.COLUMN "overlaps" with a table called TABLE_COLUMN for MySQL --- .../src/main/java/org/jooq/util/JavaGenerator.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/jOOQ-codegen/src/main/java/org/jooq/util/JavaGenerator.java b/jOOQ-codegen/src/main/java/org/jooq/util/JavaGenerator.java index 625bf4b406..a3d3a390f5 100644 --- a/jOOQ-codegen/src/main/java/org/jooq/util/JavaGenerator.java +++ b/jOOQ-codegen/src/main/java/org/jooq/util/JavaGenerator.java @@ -43,6 +43,7 @@ package org.jooq.util; import static java.util.Arrays.asList; import static org.jooq.SQLDialect.MYSQL; +import static org.jooq.SQLDialect.POSTGRES; import static org.jooq.tools.StringUtils.defaultIfBlank; import static org.jooq.tools.StringUtils.defaultString; import static org.jooq.util.AbstractGenerator.Language.JAVA; @@ -4980,7 +4981,8 @@ public class JavaGenerator extends AbstractGenerator { } // [#3942] PostgreSQL treats UDTs and table types in similar ways - else if (db.getTable(schema, u) != null) { + // [#5334] In MySQL, the user type is (ab)used for synthetic enum types. This can lead to accidental matches here + else if (db.getDialect().family() == POSTGRES && db.getTable(schema, u) != null) { type = getStrategy().getFullJavaClassName(db.getTable(schema, u), udtMode); } @@ -5037,7 +5039,8 @@ public class JavaGenerator extends AbstractGenerator { sb.append(".getDataType()"); } // [#3942] PostgreSQL treats UDTs and table types in similar ways - else if (db.getTable(schema, u) != null) { + // [#5334] In MySQL, the user type is (ab)used for synthetic enum types. This can lead to accidental matches here + else if (db.getDialect().family() == POSTGRES && db.getTable(schema, u) != null) { sb.append(getStrategy().getFullJavaIdentifier(db.getTable(schema, u))); sb.append(".getDataType()"); }