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

DBName with hyphens creates invalid code #3444

Closed
Wattos opened this issue Jul 10, 2024 · 2 comments · Fixed by #3447
Closed

DBName with hyphens creates invalid code #3444

Wattos opened this issue Jul 10, 2024 · 2 comments · Fixed by #3447
Assignees
Labels
Milestone

Comments

@Wattos
Copy link

Wattos commented Jul 10, 2024

Expected behavior

The generated code should be correct OR ebean should be explicit about not supporting Database names with hyphens

Actual behavior

The annotation processor fails with a compile exception as it generates incorrect code

Steps to reproduce

Create an entity and assign it to a database that has a hyphen in its name.

@DBName(name = "kebab-db-name") 
public class Entity {
}

Context:
We make use of ebean within the Quarkus framework and configure ebean with microprofile config.

We end up with configurations such as

quarkus.ebean.some-custom-database.enabled=true

At this point, we have to use underscores (which is not the end of the world), but is inconsistent with all of the other configuration parameters that use hyphens instead.

e.g.

%prod.mp.messaging.connector.smallrye-kafka.security.protocol=SASL_SSL

This seems to happen in the SimpleModuleInfoWriter.java (

writeMethodComment("Entities for @DbName(name=\"%s\"))", dbName);
) where the database name is used directly in the method name.

A solution could be to simply remove any characters that cannot be used in method names in this function.

@Wattos
Copy link
Author

Wattos commented Jul 10, 2024

Please note, this is just a minor issue as a workaround exists with using snake_case for the database name, but creates slightly less elegant code (as it creates inconsistencies in the Quarkus ecosystem)

@rbygrave rbygrave linked a pull request Jul 16, 2024 that will close this issue
@rbygrave rbygrave self-assigned this Jul 16, 2024
@rbygrave rbygrave added the bug label Jul 16, 2024
@rbygrave rbygrave added this to the 14.5.0 milestone Jul 16, 2024
@Wattos
Copy link
Author

Wattos commented Jul 17, 2024

@rbygrave thank you for the quick fix of the issue. Very much appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants