sqlboiler icon indicating copy to clipboard operation
sqlboiler copied to clipboard

Feature Request: make enums their own type

Open jstrohm-triller opened this issue 7 years ago • 9 comments

I'm new to Go and SQLBoiler but would it be possible to have enums be their own type like this?

type Workday 
const (
  WorkdayMonday Workday  = "monday"
  WorkdayTuesday Workday  = "tuesday"
  WorkdayWednesday Workday = "wednesday"
  WorkdayThursday Workday = "thursday"
  WorkdayFriday Workday  = "friday"
)

jstrohm-triller avatar Nov 12 '18 19:11 jstrohm-triller

This is definitely something that could be implemented but it requires a larger change to be useful.

In SQLBoiler there's still a few places where it's useful to build strings with + and this prevents that from happening because it requires a conversion from Workday to string for it to work.

aarondl avatar Nov 14 '18 06:11 aarondl

This could be done as part of #426 but it's a breaking change.

aarondl avatar Jan 02 '19 17:01 aarondl

This could possibly be done now as #426 is finished. Though it is a breaking change.

aarondl avatar Jan 09 '19 20:01 aarondl

I would love to see this in SQLBoiler. Maybe as an option in sqlboiler.toml?

Atrox avatar Jan 17 '19 14:01 Atrox

Since it is a breaking change yes, an opt-in flag in config would do until 4.0 at which point that'd be the only way. This really is only made possible by 426 though since those types will be pain to deal with in any other scenario.

aarondl avatar Jan 20 '19 17:01 aarondl

Happy to see a PR for this at some point.

aarondl avatar May 20 '19 20:05 aarondl

I'd love to help. As far as I understood is #426 resolved and the feature should be behind a feature flag. Correct?

tomscholz avatar Sep 01 '20 14:09 tomscholz

Okay, so I'm currently browsing the repo and making myself familiar with how the project is structured. The template for the boil_types.go is located under templates/singleton/boil_types.go.

There is templatebin/bindata.go which is the only place I could find where templates/singleton/boil_types.go is being used, but I'm unsure what bindata.go exactly does. Any guidance here would be helpful :)

Cheers, Tom

tomscholz avatar Sep 02 '20 08:09 tomscholz

@tomscholz take a look at the contributing guide. Talks about a tool called go-bindata and where to get it. The boil.sh build script has ways to take the modified templates and turn it into that bindata.go

aarondl avatar Sep 02 '20 09:09 aarondl