fix: sql or protobuf name cannot use the suffix _test

This commit is contained in:
zhuyasen
2024-03-23 19:53:51 +08:00
parent 6e44dfbf43
commit d01e88e876
12 changed files with 274 additions and 18 deletions

View File

@@ -45,6 +45,15 @@ func (a *Args) checkValid() error {
if a.SQL == "" && a.DDLFile == "" && (a.DBDsn == "" && a.DBTable == "") {
return errors.New("you must specify sql or ddl file")
}
if a.DBTable != "" {
tables := strings.Split(a.DBTable, ",")
for _, name := range tables {
if strings.HasSuffix(name, "_test") {
return fmt.Errorf(`the table name (%s) suffix "_test" is not supported for code generation, please delete suffix "_test" or change it to another name. `, name)
}
}
}
if a.DBDriver == "" {
a.DBDriver = parser.DBDriverMysql
} else if a.DBDriver == parser.DBDriverSqlite {