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

Numerical enum fails #28

Closed
betim opened this issue Dec 19, 2019 · 4 comments
Closed

Numerical enum fails #28

betim opened this issue Dec 19, 2019 · 4 comments
Labels
bug Something isn't working
Milestone

Comments

@betim
Copy link

betim commented Dec 19, 2019

Hi,

I just noticed that when an enum has a numerical numerator, the thing crashes quite ambiguously:

Generating enum sql builder files...
14:18: expected expression (and 2 more errors)

Also a feature request: can you add a flag say -overwrite which will only overwrite files and keep other things intact, for now I've commented:

	// fmt.Println("Cleaning up destination directory...")
	// err := utils.CleanUpGeneratedFiles(destDir)
	// utils.PanicOnError(err)

Cheers

@go-jet
Copy link
Owner

go-jet commented Dec 20, 2019

Hi @betim thanks for reporting the issue with generating enum files.

Regarding feature request, could you describe you use case for overwriting files. Why do you have to keep other code in generator folder?

@betim
Copy link
Author

betim commented Dec 20, 2019

At first I wanted to have a controller directory inside db-name directory with all HTTP controllers. But now I see that it's not a good idea.

On the other hand, it would be great if there is a mode where you generate a directory for a table, say dbn.tbl and a folder structure would be:

dbn/
  tbl/
    enum.go
    model.go
    type.go

in this case it would be great to have the -overwrite flag so, you could put a controller.go there where you implement some business logic or the HTTP handlers.

I'm not sure if there are patterns like this, but I think this kind of separation would be quite clean.

@go-jet
Copy link
Owner

go-jet commented Dec 21, 2019

It is usually a bad practice to mix generated and custom files in the same directory. In the future there might be a feature for a user to specify folder structure, but it is not a priority now. Even then, unless there are valid use cases, generator will clean up directory before generating the files, to avoid some dangerous edge cases. For instance if the user deletes table from the database, and generator works in overwrite mode, sql builder and model files for that table will remain.

@go-jet go-jet added the bug Something isn't working label Feb 17, 2020
@go-jet go-jet added this to the Version 2.2.0 milestone Feb 17, 2020
@go-jet
Copy link
Owner

go-jet commented Feb 17, 2020

Crash on generating enum SQL Builder files when database enum contains numeric values is fixed with release the v2.2.0.
Generator will construct go field name by prepending enum name to enum value, if enum value does not start with a literal.

@go-jet go-jet closed this as completed Feb 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants