add test
This commit is contained in:
parent
433efbe102
commit
8ea8ef929c
|
@ -209,3 +209,39 @@ func TestDBVersion(t *testing.T) {
|
||||||
|
|
||||||
fmt.Println(testEngine.Dialect().URI().DBType, "version is", version)
|
fmt.Println(testEngine.Dialect().URI().DBType, "version is", version)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestGetColumns(t *testing.T) {
|
||||||
|
if testEngine.Dialect().URI().DBType != schemas.POSTGRES {
|
||||||
|
t.Skip()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
type TestCommentStruct struct {
|
||||||
|
HasComment int
|
||||||
|
NoComment int
|
||||||
|
}
|
||||||
|
|
||||||
|
assertSync(t, new(TestCommentStruct))
|
||||||
|
|
||||||
|
comment := "this is a comment"
|
||||||
|
sql := fmt.Sprintf("comment on column %s.%s is '%s'", testEngine.TableName(new(TestCommentStruct), true), "has_comment", comment)
|
||||||
|
_, err := testEngine.Exec(sql)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
tables, err := testEngine.DBMetas()
|
||||||
|
assert.NoError(t, err)
|
||||||
|
tableName := testEngine.GetColumnMapper().Obj2Table("TestCommentStruct")
|
||||||
|
var hasComment, noComment string
|
||||||
|
for _, table := range tables {
|
||||||
|
if table.Name == tableName {
|
||||||
|
col := table.GetColumn("has_comment")
|
||||||
|
assert.NotNil(t, col)
|
||||||
|
hasComment = col.Comment
|
||||||
|
col2 := table.GetColumn("no_comment")
|
||||||
|
assert.NotNil(t, col2)
|
||||||
|
noComment = col2.Comment
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert.Equal(t, comment, hasComment)
|
||||||
|
assert.Zero(t, noComment)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue