go:1.15.5
gf:1.14.6
手动在数据库表test中添加user字段
或
用g.DB().Exec()执行往数据表test中添加user字段
没有用model 模型直接 g.DB().Table('test').Insert(g.map{"user":1})
提交时候,提示 no column of name user found for test 错误
重启服务,则正常运行;
群里讨论是数据表结构缓存原因, 而g.DB().GetCache() 无法获取缓存信息,导致无法清除缓存;
分析gf源码时在 gdb 运行调用 TableFields 生成表结构缓存(不是数据缓存),键值是fmt.Sprintf(mysql_tablefields%s_%s@group:%s, table, checkSchema, d.GetGroup()),
目前应急方案
在 gf/database/gdb/gdb_core.go 文件中添加
func (c *Core) Rmcache(table string) error{
    if _,err :=internalCache.Remove(fmt.Sprintf(`mysql_table_fields_%s_@group:%s`, table, c.GetGroup()));err != nil {
        return err
    } 
    return nil
}想要刷新表缓存时,直接调用 g.DB().Table('test').Rmcache(table)即可,但总感觉像山寨的。。
