fix: 复合主键表 shop_players 的 update 改用原生 SQL
ent 的 Update().Where() 对复合主键表会报 "sql/sqlgraph: invalid composite id for update table",这是 ent 框架已知的限制(field.ID 复合主键仅对 edge schema 完整支持)。同表的 Create/Delete/Query 操作不受影响,仅 Update 需要绕过。在 ServiceContext 中暴露底层 *sql.DB 以供 ExecContext 执行原生 SQL。
This commit is contained in:
@@ -27,6 +27,7 @@ type ServiceContext struct {
|
||||
UsersRpc usercenter.Usercenter
|
||||
ShopModelRW *models.Client
|
||||
ShopModelRO *models.Client
|
||||
DBRW *stdsql.DB
|
||||
}
|
||||
|
||||
func NewServiceContext(c config.Config) *ServiceContext {
|
||||
@@ -68,5 +69,6 @@ func NewServiceContext(c config.Config) *ServiceContext {
|
||||
UsersRpc: usercenter.NewUsercenter(zrpc.MustNewClient(c.UsersRpcConf)),
|
||||
ShopModelRO: models.NewClient(roModelOpts...),
|
||||
ShopModelRW: models.NewClient(rwModelOpts...),
|
||||
DBRW: rawRW,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user