Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug][kotlin] sanitize model names according to convention #16267

Merged
merged 3 commits into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ public String toModelName(final String name) {
return importMapping.get(name);
}

String modifiedName = name.replaceAll("\\.", "");
String modifiedName = name.replaceAll("\\.", "").replaceAll("-", "_");

String nameWithPrefixSuffix = sanitizeKotlinSpecificNames(modifiedName);
if (!StringUtils.isEmpty(modelNamePrefix)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public void convertModelName() {
assertEquals(codegen.toModelName("Pony?"), "PonyQuestionMark");
assertEquals(codegen.toModelName("$name"), "DollarName");
assertEquals(codegen.toModelName("nam#e"), "NamHashE");
assertEquals(codegen.toModelName("$another-fake?"), "DollarAnotherMinusFakeQuestionMark");
assertEquals(codegen.toModelName("$another-fake?"), "DollarAnotherFakeQuestionMark");
assertEquals(codegen.toModelName("Pony>=>="), "PonyGreaterThanEqualGreaterThanEqual");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ public static Object[][] modelNames() {
{"$", new ModelNameTest("$", "Dollar")},
{"for", new ModelNameTest("`for`", "For")},
{"One<Two", new ModelNameTest("One<Two", "OneLessThanTwo")},
{"One-Two", new ModelNameTest("One-Two", "OneTwo")},
{"this is a test", new ModelNameTest("this is a test", "ThisIsATest")}
};
}
Expand Down
Loading