Closed zishiguo closed 8 months ago
It poses by func (UserFollow) TableName() string
, Gorm Sharding my not full supports of it.
@huacnlee so I avoid to use soft delete feature when using sharding with mysql ?
No, You can try to remove custom table name func. To use the default table name.
In default, the default table name isuser_follows
not user_follow
.
@huacnlee thanks, I adjust table name from user_follow
touser_follows
. I have a try with your solution.
@huacnlee The problem still exists. It shows same error.
你可以这样改 找到sharding.go文件,定位到412行 stmt.FromItems = newTable stmt.OrderBy = replaceOrderByTableName(stmt.OrderBy, tableName, newTable.Name.Name) stQuery = stmt.String() 把这3行注释掉,然后新增 stQuery = strings.ReplaceAll(stmt.String(),tableName,newTable.Name.Name)
下面的更新和删除也需要这样改,不然更新和删除也会失败 更新和删除需要注释 stmt.TableName = newTable stQuery = stmt.String() 新增 stQuery = strings.ReplaceAll(stmt.String(),tableName,newTable.Name.Name)
@254408599 thanks
@254408599 Can you launch a PR ?
@huacnlee
GORM Playground Link
568
Description
I also met this question sharding Error 1054: Unknown column 'ny_order.deleted_at' in 'where clause'
detailed error as follows