Merge pull request #387 from safaci2000/feature/enums
Adding support for enum model AllValues
This commit is contained in:
commit
6a0798eb06
2 changed files with 7 additions and 2 deletions
|
|
@ -156,6 +156,12 @@ const (
|
||||||
{{- end}}
|
{{- end}}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var {{$enumTemplate.TypeName}}AllValues = []{{$enumTemplate.TypeName}} {
|
||||||
|
{{- range $_, $value := .Values}}
|
||||||
|
{{valueName $value}},
|
||||||
|
{{- end}}
|
||||||
|
}
|
||||||
|
|
||||||
func (e *{{$enumTemplate.TypeName}}) Scan(value interface{}) error {
|
func (e *{{$enumTemplate.TypeName}}) Scan(value interface{}) error {
|
||||||
var enumValue string
|
var enumValue string
|
||||||
switch val := value.(type) {
|
switch val := value.(type) {
|
||||||
|
|
|
||||||
|
|
@ -171,6 +171,7 @@ func TestGeneratorTemplate_Model_RenameFilesAndTypes(t *testing.T) {
|
||||||
|
|
||||||
mpaaRating := file2.Exists(t, defaultModelPath, "mpaa_rating_enum.go")
|
mpaaRating := file2.Exists(t, defaultModelPath, "mpaa_rating_enum.go")
|
||||||
require.Contains(t, mpaaRating, "type MpaaRatingEnum string")
|
require.Contains(t, mpaaRating, "type MpaaRatingEnum string")
|
||||||
|
require.Contains(t, mpaaRating, "MpaaRatingEnumAllValues")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGeneratorTemplate_Model_SkipTableAndEnum(t *testing.T) {
|
func TestGeneratorTemplate_Model_SkipTableAndEnum(t *testing.T) {
|
||||||
|
|
@ -268,7 +269,6 @@ func UseSchema(schema string) {
|
||||||
FilmList = FilmList.FromSchema(schema)
|
FilmList = FilmList.FromSchema(schema)
|
||||||
}
|
}
|
||||||
`)
|
`)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGeneratorTemplate_SQLBuilder_ChangeTypeAndFileName(t *testing.T) {
|
func TestGeneratorTemplate_SQLBuilder_ChangeTypeAndFileName(t *testing.T) {
|
||||||
|
|
@ -366,7 +366,6 @@ func TestGeneratorTemplate_SQLBuilder_DefaultAlias(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGeneratorTemplate_Model_AddTags(t *testing.T) {
|
func TestGeneratorTemplate_Model_AddTags(t *testing.T) {
|
||||||
|
|
||||||
err := postgres.Generate(
|
err := postgres.Generate(
|
||||||
tempTestDir,
|
tempTestDir,
|
||||||
dbConnection,
|
dbConnection,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue