struct增加字段后,Sync执行的时候,语句中表名为空 #426

Open
opened 2016-07-20 11:13:24 +00:00 by big-hippo · 3 comments
big-hippo commented 2016-07-20 11:13:24 +00:00 (Migrated from github.com)

日志显示:ALTER TABLE ADD test1 INT NOT NULL DEFAULT -1 ;
跟踪发现这里有问题:
} else {
session := engine.NewSession()
session.Statement.RefTable = table
session.Statement.tableName = tbName
defer session.Close()
err = session.addColumn(col.Name)
}
后续addColumn函数中,statement判断表名部分使用了tblname和alttbname,这里只设置了tableName,导致
func (s *Statement) genAddColumnStr(col *core.Column) (string, []interface{}) {
quote := s.Engine.Quote
sql := fmt.Sprintf("ALTER TABLE %v ADD %v;", quote(s.TableName()),
col.String(s.Engine.dialect))
return sql, []interface{}{}
}
s.TableName()函数读不出表名

日志显示:ALTER TABLE ADD `test1` INT NOT NULL DEFAULT -1 ; 跟踪发现这里有问题: } else { session := engine.NewSession() session.Statement.RefTable = table session.Statement.tableName = tbName defer session.Close() err = session.addColumn(col.Name) } 后续addColumn函数中,statement判断表名部分使用了tblname和alttbname,这里只设置了tableName,导致 func (s *Statement) genAddColumnStr(col *core.Column) (string, []interface{}) { quote := s.Engine.Quote sql := fmt.Sprintf("ALTER TABLE %v ADD %v;", quote(s.TableName()), col.String(s.Engine.dialect)) return sql, []interface{}{} } s.TableName()函数读不出表名

Is your version the latest xorm?

Is your version the latest xorm?
big-hippo commented 2016-07-21 02:28:02 +00:00 (Migrated from github.com)

go get -u -v github.com/go-xorm/xorm
xorm v0.5.5.0711
更新之后,故障依旧

go get -u -v github.com/go-xorm/xorm xorm v0.5.5.0711 更新之后,故障依旧

有更多细节代码吗?

有更多细节代码吗?
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: xorm/xorm#426
No description provided.