Add test for dump table with default value (#1950)

Confirm #1391 resolved.

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1950
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
Lunny Xiao 2021-06-12 20:27:49 +08:00
parent 7fd6356a85
commit 00ee06fdd5
1 changed files with 17 additions and 0 deletions

View File

@ -176,6 +176,23 @@ func TestDumpTables(t *testing.T) {
}
}
func TestDumpTables2(t *testing.T) {
assert.NoError(t, PrepareEngine())
type TestDumpTableStruct2 struct {
Id int64
Created time.Time `xorm:"Default CURRENT_TIMESTAMP"`
}
assertSync(t, new(TestDumpTableStruct2))
fp := fmt.Sprintf("./dump2-%v-table.sql", testEngine.Dialect().URI().DBType)
os.Remove(fp)
tb, err := testEngine.TableInfo(new(TestDumpTableStruct2))
assert.NoError(t, err)
assert.NoError(t, testEngine.(*xorm.Engine).DumpTablesToFile([]*schemas.Table{tb}, fp))
}
func TestSetSchema(t *testing.T) {
assert.NoError(t, PrepareEngine())