MCPcopy Index your code
hub / github.com/go-dev-frame/sponge / checkValid

Method checkValid

pkg/sql2code/sql2code.go:47–71  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

45}
46
47func (a *Args) checkValid() error {
48 if a.SQL == "" && a.DDLFile == "" && (a.DBDsn == "" && a.DBTable == "") {
49 return errors.New("you must specify sql or ddl file")
50 }
51 if a.DBTable != "" {
52 tables := strings.Split(a.DBTable, ",")
53 for _, name := range tables {
54 if strings.HasSuffix(name, "_test") {
55 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)
56 }
57 }
58 }
59
60 if a.DBDriver == "" {
61 a.DBDriver = parser.DBDriverMysql
62 } else if a.DBDriver == parser.DBDriverSqlite {
63 if !gofile.IsExists(a.DBDsn) {
64 return fmt.Errorf("sqlite db file %s not found in local host", a.DBDsn)
65 }
66 }
67 if a.fieldTypes == nil {
68 a.fieldTypes = make(map[string]string)
69 }
70 return nil
71}
72
73func getSQL(args *Args) (string, map[string]string, error) {
74 if args.SQL != "" {

Callers 1

GenerateFunction · 0.45

Calls 2

IsExistsFunction · 0.92
ErrorfMethod · 0.80

Tested by

no test coverage detected