[#2781] Disambiguate collisions between enum literals and package names
This commit is contained in:
parent
e171b70f21
commit
fd2d3280c8
@ -132,6 +132,11 @@ class GeneratorStrategyWrapper extends AbstractGeneratorStrategy {
|
||||
if (identifier.equals(getJavaIdentifier(e.getContainer()))) {
|
||||
return identifier + "_";
|
||||
}
|
||||
|
||||
// [#2781] Disambiguate collisions with the leading package name
|
||||
if (identifier.equals(getJavaPackageName(e.getContainer()).replaceAll("\\..*", ""))) {
|
||||
return identifier + "_";
|
||||
}
|
||||
}
|
||||
|
||||
return identifier;
|
||||
@ -316,7 +321,14 @@ class GeneratorStrategyWrapper extends AbstractGeneratorStrategy {
|
||||
|
||||
@Override
|
||||
public String getJavaMemberName(Definition definition, Mode mode) {
|
||||
return convertToJavaIdentifier(delegate.getJavaMemberName(definition, mode));
|
||||
String identifier = convertToJavaIdentifier(delegate.getJavaMemberName(definition, mode));
|
||||
|
||||
// [#2781] Disambiguate collisions with the leading package name
|
||||
if (identifier.equals(getJavaPackageName(definition, mode).replaceAll("\\..*", ""))) {
|
||||
return identifier + "_";
|
||||
}
|
||||
|
||||
return identifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -1072,7 +1072,12 @@ public class JavaGenerator extends AbstractGenerator {
|
||||
out.println("public enum %s[[before= implements ][%s]] {", className, interfaces);
|
||||
|
||||
for (String literal : e.getLiterals()) {
|
||||
final String identifier = GenerationUtil.convertToJavaIdentifier(literal);
|
||||
String identifier = GenerationUtil.convertToJavaIdentifier(literal);
|
||||
|
||||
// [#2781] Disambiguate collisions with the leading package name
|
||||
if (identifier.equals(getStrategy().getJavaPackageName(e).replaceAll("\\..*", ""))) {
|
||||
identifier += "_";
|
||||
}
|
||||
|
||||
out.println();
|
||||
out.tab(1).println("%s(\"%s\"),", identifier, literal);
|
||||
|
||||
@ -9,6 +9,18 @@
|
||||
</jdbc>
|
||||
<generator>
|
||||
<name>org.jooq.util.DefaultGenerator</name>
|
||||
<strategy>
|
||||
<matchers>
|
||||
<fields>
|
||||
<expression>(?i:(.*?.)?T_2781\.(.*))</expression>
|
||||
|
||||
<fieldIdentifier>
|
||||
<transform>LOWER</transform>
|
||||
<expression>$2</expression>
|
||||
</fieldIdentifier>
|
||||
</fields>
|
||||
</matchers>
|
||||
</strategy>
|
||||
<database>
|
||||
<name>org.jooq.util.postgres.PostgresDatabase</name>
|
||||
<includes>t_.*|x_.*|v_.*|V_.*|p_.*|f_.*|u_.*|(f|p)[0-9]+|s_.*</includes>
|
||||
|
||||
@ -69,12 +69,14 @@ DROP TABLE IF EXISTS t_inheritance_1_2_1/
|
||||
DROP TABLE IF EXISTS t_inheritance_1_2/
|
||||
DROP TABLE IF EXISTS t_inheritance_1_1/
|
||||
DROP TABLE IF EXISTS t_inheritance_1/
|
||||
DROP TABLE IF EXISTS t_2781/
|
||||
|
||||
DROP TYPE IF EXISTS u_address_type/
|
||||
DROP TYPE IF EXISTS u_street_type/
|
||||
DROP TYPE IF EXISTS u_book_status/
|
||||
DROP TYPE IF EXISTS u_country/
|
||||
DROP TYPE IF EXISTS u_959/
|
||||
DROP TYPE IF EXISTS u_2781/
|
||||
DROP TYPE IF EXISTS u_uuids/
|
||||
|
||||
CREATE TYPE u_uuids AS (
|
||||
@ -91,6 +93,7 @@ CREATE TYPE u_959 AS ENUM('abstract', 'assert', 'boolean', 'break', 'byte', 'cas
|
||||
'protected', 'public', 'return', 'short', 'static', 'strictfp',
|
||||
'super', 'switch', 'synchronized', 'this', 'throw', 'throws',
|
||||
'transient', 'true', 'try', 'void', 'volatile', 'while')/
|
||||
CREATE TYPE u_2781 AS ENUM('org', 'jooq')/
|
||||
CREATE TYPE u_book_status AS ENUM ('SOLD OUT', 'ON STOCK', 'ORDERED')/
|
||||
CREATE TYPE u_country AS ENUM ('Brazil', 'England', 'Germany')/
|
||||
|
||||
@ -113,6 +116,12 @@ CREATE TYPE u_address_type AS (
|
||||
)
|
||||
/
|
||||
|
||||
CREATE TABLE t_2781 (
|
||||
org text,
|
||||
jooq text
|
||||
)
|
||||
/
|
||||
|
||||
CREATE TABLE t_inheritance_1 (
|
||||
text_1 text
|
||||
)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user