add table & column comment for postgres(add table comment for mysql) #2067
No reviewers
Labels
No Label
backport/done
backport/v1
blocked
db
oracle
db
sqlserver
duplicate
feature
cache
frontport/done
frontport/main
invalid
kind
breaking
kind
bug
kind
build
kind
dependencies
kind
docs
kind
driver
kind
enhancement
kind
feature
kind
performance
kind
proposal
kind
question
kind
refactor
kind
testing
need
feedback
need
test
proposal:accepted
RaspBerry Pi
regression
skip-changelog
upstream
wip
wontfix
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: xorm/xorm#2067
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "fanybook/xorm:master"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
让 postgres 支持字段注释,只在 v1.2.5 上测试过(不知道怎么 import master)
发现 master 分支好像大改了?模式表名带 schema 了
使用方式和 mysql 相同
You should change
dialects/postgres.go
but not there.per my comment above.
@lunny 已经移到 dialects 了,感觉 master 代码和 v1.2.5 相差很多,接口都变了
现在支持了字段注释和表注释
我发现 dialects/mysql.go 貌似没有用到 schema?mysql 里的库也相当于 pgsql 里的 schema
add column comment for postgresto add table & column comment for postgresadd table & column comment for postgresto add table & column comment for postgres(add table comment for mysql)@ -90,6 +90,14 @@ func (parser *Parser) ParseWithCache(v reflect.Value) (*schemas.Table, error) {
return nil, err
}
// if bean has Comment Method, then set table.Comment
This should be moved into
parser.Parse
Thank you very much! Could you add some tests here? I think we have some with comment for MySQL.
@ -58,0 +67,4 @@
return v.Interface().(TableComment).TableComment()
}
return ""
You should also consider it's a pointer method.
@ -351,6 +351,7 @@ func (session *Session) Sync(beans ...interface{}) error {
if err = session.addColumn(col.Name); err != nil {
return err
}
unnecessary change.
@ -26,6 +26,10 @@ func (p ParseTableName2) TableName() string {
return "p_parseTableName"
}
func (p ParseTableName2) TableComment() string {
Please also add a pointer method
How about also add simliar test cases for postgres?
parser.Parse only set table.Commet, it will be used in dialects
i don't know how to import master branch in my project
@lunny 看一下,能合并了么
@ -1001,0 +1021,4 @@
modifyColumnSQL = fmt.Sprintf("ALTER TABLE %s.%s ALTER COLUMN %s TYPE %s", quoter.Quote(db.getSchema()), quoter.Quote(tableName), quoter.Quote(col.Name), db.SQLType(col))
commentSQL += fmt.Sprintf("COMMENT ON COLUMN %s.%s.%s IS '%s'", quoter.Quote(db.getSchema()), quoter.Quote(tableName), quoter.Quote(col.Name), col.Comment)
return modifyColumnSQL + commentSQL
need a space between two SQLs
@lunny has space and semicolon
I mean in function
ModifyColumnSQL
@lunny 我不太明白,应该在哪加空格,请指点一下
@lunny 受累看一下能合并了么,之前您说在 ModifyColumnSQL 里,两段 sql 之前应该有一个空格
但是在 commentSQL 初始化的时候,这个空格就已经有了,还有一个分号
like this