add modify column comment testcase
This commit is contained in:
parent
8e2ce8c53d
commit
b0fe86421a
|
@ -289,6 +289,48 @@ func TestGetColumnsComment(t *testing.T) {
|
||||||
assert.Zero(t, noComment)
|
assert.Zero(t, noComment)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type TestCommentUpdate struct {
|
||||||
|
HasComment int `xorm:"comment('this is a comment before update')"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *TestCommentUpdate) TableName() string {
|
||||||
|
return "test_comment_struct"
|
||||||
|
}
|
||||||
|
|
||||||
|
type TestCommentUpdate2 struct {
|
||||||
|
HasComment int `xorm:"comment('this is a comment after update')"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *TestCommentUpdate2) TableName() string {
|
||||||
|
return "test_comment_struct"
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestColumnCommentUpdate(t *testing.T) {
|
||||||
|
comment := "this is a comment after update"
|
||||||
|
assertSync(t, new(TestCommentUpdate))
|
||||||
|
assert.NoError(t, testEngine.Sync(new(TestCommentUpdate2))) // modify table column comment
|
||||||
|
|
||||||
|
switch testEngine.Dialect().URI().DBType {
|
||||||
|
case schemas.POSTGRES: // only postgres dialect implement the feature of modify comment in postgres.ModifyColumnSQL
|
||||||
|
default:
|
||||||
|
t.Skip()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
tables, err := testEngine.DBMetas()
|
||||||
|
assert.NoError(t, err)
|
||||||
|
tableName := "test_comment_struct"
|
||||||
|
var hasComment string
|
||||||
|
for _, table := range tables {
|
||||||
|
if table.Name == tableName {
|
||||||
|
col := table.GetColumn(testEngine.GetColumnMapper().Obj2Table("HasComment"))
|
||||||
|
assert.NotNil(t, col)
|
||||||
|
hasComment = col.Comment
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert.Equal(t, comment, hasComment)
|
||||||
|
}
|
||||||
|
|
||||||
func TestGetColumnsLength(t *testing.T) {
|
func TestGetColumnsLength(t *testing.T) {
|
||||||
var max_length int64
|
var max_length int64
|
||||||
switch testEngine.Dialect().URI().DBType {
|
switch testEngine.Dialect().URI().DBType {
|
||||||
|
|
Loading…
Reference in New Issue