-
-
Notifications
You must be signed in to change notification settings - Fork 339
Open
Description
Describe the feature
On Postgres, we can define:
CREATE TYPE fruit AS ENUM ('orange', 'pineapple', 'peach');
Other tools that generate Go code from DB schemas, such as sqlboiler, will generate the following:
type Fruit string
// Enum values for Fruit
const (
FruitOrange Fruit = "orange"
FruitPineapple Fruit = "pineapple"
FruitPeach Fruit = "peach"
)
I was wondering if we can have the same feature in gentool
.
Motivation
Without this code generation, we run the risk of checking against the wrong string values (especially when adding/removing them from the schema).
Having this generated, would allow us to check confidently against the schema like so:
if result.Fruit == model.FruitOrange {
// TODO
}
Related Issues
#1033 - contrary to this ticket, I'd like the gentool to generate the constants for me based on the schema it already has. Not map them to manually written ones.
MrJamesThe3rd
Metadata
Metadata
Assignees
Labels
No labels