mirror of
https://gitea.com/xorm/xorm
synced 2025-10-06 00:02:41 +02:00
Fix dump bug (#1613)
Fix dump Fix dump bug Reviewed-on: https://gitea.com/xorm/xorm/pulls/1613
This commit is contained in:
@@ -375,6 +375,10 @@ func (engine *Engine) dumpTables(tables []*schemas.Table, w io.Writer, tp ...sch
|
||||
if dstDialect.URI().Schema != "" {
|
||||
tableName = fmt.Sprintf("%s.%s", dstDialect.URI().Schema, table.Name)
|
||||
}
|
||||
originalTableName := table.Name
|
||||
if engine.dialect.URI().Schema != "" {
|
||||
originalTableName = fmt.Sprintf("%s.%s", engine.dialect.URI().Schema, table.Name)
|
||||
}
|
||||
if i > 0 {
|
||||
_, err = io.WriteString(w, "\n")
|
||||
if err != nil {
|
||||
@@ -403,7 +407,7 @@ func (engine *Engine) dumpTables(tables []*schemas.Table, w io.Writer, tp ...sch
|
||||
colNames := engine.dialect.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(originalTableName))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@@ -97,6 +97,12 @@ func TestDump(t *testing.T) {
|
||||
_, err := sess.ImportFile(fp)
|
||||
assert.NoError(t, err)
|
||||
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) {
|
||||
|
Reference in New Issue
Block a user