Fix dump bug

This commit is contained in:
Lunny Xiao 2020-03-21 23:04:17 +08:00
parent a7a1dc5c42
commit 6ebe3edd7d
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
2 changed files with 7 additions and 1 deletions

View File

@ -403,7 +403,7 @@ func (engine *Engine) dumpTables(tables []*schemas.Table, w io.Writer, tp ...sch
colNames := engine.dialect.Quoter().Join(cols, ", ") colNames := engine.dialect.Quoter().Join(cols, ", ")
destColNames := dstDialect.Quoter().Join(cols, ", ") destColNames := dstDialect.Quoter().Join(cols, ", ")
rows, err := engine.DB().QueryContext(engine.defaultContext, "SELECT "+colNames+" FROM "+engine.Quote(tableName)) rows, err := engine.DB().QueryContext(engine.defaultContext, "SELECT "+colNames+" FROM "+engine.Quote(table.Name))
if err != nil { if err != nil {
return err return err
} }

View File

@ -97,6 +97,12 @@ func TestDump(t *testing.T) {
_, err := sess.ImportFile(fp) _, err := sess.ImportFile(fp)
assert.NoError(t, err) assert.NoError(t, err)
assert.NoError(t, sess.Commit()) assert.NoError(t, sess.Commit())
for _, tp := range []schemas.DBType{schemas.SQLITE, schemas.MYSQL, schemas.POSTGRES, schemas.MSSQL} {
t.Run(fmt.Sprintf("dump_%v", tp), func(t *testing.T) {
assert.NoError(t, testEngine.DumpAllToFile(fp, tp))
})
}
} }
func TestSetSchema(t *testing.T) { func TestSetSchema(t *testing.T) {