Merge pull request #13010 from owyke/another-solution-to-kotlin-code-gen-issue

[#13008] Unquote keyword when mapping one to many relation
This commit is contained in:
Lukas Eder 2022-02-08 13:42:58 +01:00 committed by GitHub
commit 6063896ec0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View File

@ -5941,9 +5941,10 @@ public class JavaGenerator extends AbstractGenerator {
for (ForeignKeyDefinition foreignKey : foreignKeys) {
final String referencedTableClassName = out.ref(getStrategy().getFullJavaClassName(foreignKey.getReferencedTable()));
final String keyMethodName = out.ref(getStrategy().getJavaMethodName(foreignKey));
final String unquotedKeyMethodName = keyMethodName.replace("`", "");
if (kotlin)
out.println("private lateinit var _%s: %s", keyMethodName, referencedTableClassName);
out.println("private lateinit var _%s: %s", unquotedKeyMethodName, referencedTableClassName);
else
out.println("private transient %s _%s;", referencedTableClassName, keyMethodName);
}
@ -5956,6 +5957,7 @@ public class JavaGenerator extends AbstractGenerator {
: out.ref(getStrategy().getFullJavaIdentifier(foreignKey), 2);
final String referencedTableClassName = out.ref(getStrategy().getFullJavaClassName(foreignKey.getReferencedTable()));
final String keyMethodName = out.ref(getStrategy().getJavaMethodName(foreignKey));
final String unquotedKeyMethodName = keyMethodName.replace("`", "");
out.javadoc(
"Get the implicit join path to the <code>" + foreignKey.getReferencedTable().getQualifiedName() + "</code> table"
@ -5968,10 +5970,10 @@ public class JavaGenerator extends AbstractGenerator {
}
else if (kotlin) {
out.println("%sfun %s(): %s {", visibility(), keyMethodName, referencedTableClassName);
out.println("if (!this::_%s.isInitialized)", keyMethodName);
out.println("_%s = %s(this, %s)", keyMethodName, referencedTableClassName, keyFullId);
out.println("if (!this::_%s.isInitialized)", unquotedKeyMethodName);
out.println("_%s = %s(this, %s)", unquotedKeyMethodName, referencedTableClassName, keyFullId);
out.println();
out.println("return _%s;", keyMethodName);
out.println("return _%s;", unquotedKeyMethodName);
out.println("}");
}
else {

View File

@ -64,6 +64,7 @@ Authors and contributors of jOOQ or parts of jOOQ in alphabetical order:
- Vladimir Vinogradov
- Vojtech Polivka
- Wang Gaoyuan
- Wyke Oskar
- Zoltan Tamasi
See the following website for details about contributing to jOOQ: