fix dump to other databases

This commit is contained in:
Lunny Xiao 2017-01-03 14:44:30 +08:00
parent 44b70cccf4
commit 2189b36884
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
1 changed files with 4 additions and 1 deletions

View File

@ -535,18 +535,21 @@ func (engine *Engine) dumpAll(w io.Writer, tp ...core.DbType) error {
// DumpAll dump database all table structs and data to w with specify db type // DumpAll dump database all table structs and data to w with specify db type
func (engine *Engine) dumpTables(tables []*core.Table, w io.Writer, tp ...core.DbType) error { func (engine *Engine) dumpTables(tables []*core.Table, w io.Writer, tp ...core.DbType) error {
var dialect core.Dialect var dialect core.Dialect
var distDBName string
if len(tp) == 0 { if len(tp) == 0 {
dialect = engine.dialect dialect = engine.dialect
distDBName = string(engine.dialect.DBType())
} else { } else {
dialect = core.QueryDialect(tp[0]) dialect = core.QueryDialect(tp[0])
if dialect == nil { if dialect == nil {
return errors.New("Unsupported database type") return errors.New("Unsupported database type")
} }
dialect.Init(nil, engine.dialect.URI(), "", "") dialect.Init(nil, engine.dialect.URI(), "", "")
distDBName = string(tp[0])
} }
_, err := io.WriteString(w, fmt.Sprintf("/*Generated by xorm v%s %s, from %s to %s*/\n\n", _, err := io.WriteString(w, fmt.Sprintf("/*Generated by xorm v%s %s, from %s to %s*/\n\n",
Version, time.Now().In(engine.TZLocation).Format("2006-01-02 15:04:05"), engine.dialect.DBType(), dialect.DBType())) Version, time.Now().In(engine.TZLocation).Format("2006-01-02 15:04:05"), engine.dialect.DBType(), strings.ToUpper(distDBName)))
if err != nil { if err != nil {
return err return err
} }