Add the ability to use custom generic types with non std inner types

- fix #442

- Since handling all edge cases for generic type parsing is not trivial, users will specify the fields manually.
- To support more than one import per type, add an additional field for extra imports per type.

- Add examples for defining those types in the current tests that show how to define custom types.
This commit is contained in:
markvai 2025-03-27 17:42:27 +02:00
parent 33c1d9e663
commit 0947de0628
3 changed files with 42 additions and 26 deletions

View file

@ -106,10 +106,10 @@ func getTableModelImports(modelType TableModel, tableMetaData metadata.Table) []
importPaths := map[string]bool{}
for _, columnMetaData := range tableMetaData.Columns {
field := modelType.Field(columnMetaData)
importPath := field.Type.ImportPath
if importPath != "" {
importPaths[importPath] = true
for _, importPath := range append([]string{field.Type.ImportPath}, field.Type.AdditionalImportPaths...) {
if importPath != "" {
importPaths[importPath] = true
}
}
}
@ -207,8 +207,9 @@ func (f TableModelField) TagsString() string {
// Type represents type of the struct field
type Type struct {
ImportPath string
Name string
ImportPath string
AdditionalImportPaths []string
Name string
}
// NewType creates new type for dummy object