You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I customize the generator to use a model with a generic field, the generator produces invalid model in case the generic field contains a non-stdlib type:
import"github.com/google/uuid"// generator customization snippetUseField(func(column metadata.Column) template.TableModelField {
defaultTableModelField:=template.DefaultTableModelField(column)
switchcolumn.Name {
case"col1":
defaultTableModelField.Type=template.NewType(sql.Null[string]{})
case"col2":
defaultTableModelField.Type=template.NewType(uuid.UUID{})
case"col3":
defaultTableModelField.Type=template.NewType(sql.Null[uuid.UUID]{})
}
returndefaultTableModelField
})
// generated invalid model.gopackage model
import (
"database/sql""github.com/google/uuid"
)
typeTstruct {
Col1 sql.Null[string]
Col2 uuid.UUIDCol3 sql.Null[github.com/google/uuid.UUID] // invalid
}
// failed to process database : failed to generate model types: failed to generate table model types: failed to save 't' model type: failed to format 't', check 'gen/model/t.go' for syntax errors: 21:26: missing ',' in type argument list
Expected behavior
I expected the generator to produce a correct model file:
Environment:
Describe the bug
If I customize the generator to use a model with a generic field, the generator produces invalid model in case the generic field contains a non-stdlib type:
Expected behavior
I expected the generator to produce a correct model file:
Code snippet
Full runnable example:
The text was updated successfully, but these errors were encountered: