Add more UseSchema tests.

Rename newly generated file to avoid potentional conflict with tables named table or views named view.
This commit is contained in:
go-jet 2023-04-02 13:58:44 +02:00
parent a9aa25416a
commit 5e34bef288
10 changed files with 250 additions and 160 deletions

View file

@ -183,19 +183,20 @@ func processTableSQLBuilder(fileTypes, dirPath string,
func generateUseSchemaFunc(dirPath, fileTypes string, builders []TableSQLBuilder) {
basePath := path.Join(dirPath, builders[0].Path)
fmt.Printf("Generating global `UseSchema` method for %s\n", fileTypes)
text, err := generateTemplate(
autoGenWarningTemplate+tableSqlBuilderSetSchemaTemplate,
builders,
template.FuncMap{
"package": func() string { return builders[0].PackageName() },
"type": func() string { return fileTypes },
},
)
throw.OnError(err)
err = utils.SaveGoFile(basePath, fileTypes, text)
basePath := path.Join(dirPath, builders[0].Path)
fileName := fileTypes + "_use_schema"
err = utils.SaveGoFile(basePath, fileName, text)
throw.OnError(err)
}