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

Error in table with ENUM field. #28

Closed
janierj opened this issue Sep 25, 2019 · 5 comments
Closed

Error in table with ENUM field. #28

janierj opened this issue Sep 25, 2019 · 5 comments
Labels
enhancement New feature or request

Comments

@janierj
Copy link

janierj commented Sep 25, 2019

I have a MySQL database with the following table

CREATE TABLE `qp1_integracao` ( `ID` INTEGER(11) NOT NULL AUTO_INCREMENT, `AGE` INTEGER(10) NOT NULL, `ENUMCOLUMN` ENUM('UOL', 'GOOGLE', 'BUSCAPE') NOT NULL, PRIMARY KEY (`ID`) ) ENGINE=InnoDB;

...when I run the program thows the following Exception

	at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:784) [spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
	at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:765) [spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:319) [spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1204) [spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
	at org.blackdread.sqltojava.SqlToJavaApplication.main(SqlToJavaApplication.java:45) [classes/:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_171]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_171]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_171]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_171]
	at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.1.8.RELEASE.jar:2.1.8.RELEASE]
Caused by: java.lang.IllegalStateException: An enum field must have its enum entity name set
	at org.blackdread.sqltojava.util.JdlUtils.lambda$writeField$0(JdlUtils.java:115) ~[classes/:na]
	at java.util.Optional.orElseThrow(Optional.java:290) ~[na:1.8.0_171]
	at org.blackdread.sqltojava.util.JdlUtils.writeField(JdlUtils.java:115) ~[classes/:na]
	at org.blackdread.sqltojava.util.JdlUtils.writeEntity(JdlUtils.java:90) ~[classes/:na]
	at org.blackdread.sqltojava.service.logic.ExportService.export(ExportService.java:61) ~[classes/:na]
	at org.blackdread.sqltojava.SqlToJavaApplication.run(SqlToJavaApplication.java:53) [classes/:na]
	at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:781) [spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
	... 10 common frames omitted

Do not recognize the ENUM column type ?, or it needs an specific treatment ?

@Blackdread
Copy link
Owner

I did not support the ENUM type from MySQL, you can do a pull request eventually to add support for it.
You can have a look at SqlJdlTypeService

@Blackdread Blackdread added the enhancement New feature or request label Aug 24, 2020
@Blackdread
Copy link
Owner

I have added support for ENUM, still need to add some logic but not much is needed.
Also added tests for mysql 5.7 and 8+, any input to improve generated JDL?

@octgsoftware
Copy link
Contributor

What needs to be done to resolve this issue? I am not sure of the current status.

@Blackdread
Copy link
Owner

I do not remember what else was done but I think we can check the different test cases you added and have an enum type in DB then see result

@octgsoftware
Copy link
Contributor

I already have a test that covers native enum for both Postgres and MySQL. This can be closed.

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

No branches or pull requests

3 participants