Adding support for enum model AllValues

Fixes #368

ChangeLog:
  - Updating test mysql version as it no longer exists.
  - Add a simple validation test
This commit is contained in:
Samir Faci 2024-09-18 12:09:43 -04:00
parent b835e25665
commit 42a37c09d0
4 changed files with 10 additions and 3 deletions

View file

@ -16,7 +16,7 @@ jobs:
POSTGRES_DB: jetdb
PGPORT: 50901
- image: circleci/mysql:8.0.27
- image: circleci/mysql:8.0
command: [ --default-authentication-plugin=mysql_native_password ]
environment:
MYSQL_ROOT_PASSWORD: jet

View file

@ -156,6 +156,12 @@ const (
{{- end}}
)
var {{$enumTemplate.TypeName}}_AllValues = []{{$enumTemplate.TypeName}} {
{{- range $_, $value := .Values}}
{{valueName $value}},
{{- end}}
}
func (e *{{$enumTemplate.TypeName}}) Scan(value interface{}) error {
var enumValue string
switch val := value.(type) {

View file

@ -13,7 +13,7 @@ services:
- ./testdata/init/postgres:/docker-entrypoint-initdb.d
mysql:
image: mysql:8.0.27
image: mysql:8.0
command: ['--default-authentication-plugin=mysql_native_password', '--log_bin_trust_function_creators=1']
restart: always
environment:

View file

@ -171,6 +171,7 @@ func TestGeneratorTemplate_Model_RenameFilesAndTypes(t *testing.T) {
mpaaRating := file2.Exists(t, defaultModelPath, "mpaa_rating_enum.go")
require.Contains(t, mpaaRating, "type MpaaRatingEnum string")
require.Contains(t, mpaaRating, "MpaaRatingEnum_AllValues")
}
func TestGeneratorTemplate_Model_SkipTableAndEnum(t *testing.T) {