go-gorm / sharding

High performance table sharding plugin for Gorm.
MIT License
275 stars 60 forks source link

表名未全部替换 #175

Open 5amch3n opened 2 months ago

5amch3n commented 2 months ago

我同时使用了 soft_delete,它在 where 中会加入 "表名.deleted_at = 0" 这样的条件,如

SELECT * FROM `t_box_file` WHERE (owner = 57 AND parent_id = 0 AND name like 'New Folder%') AND `t_box_file`.`deleted_at` = 0

sharding 只得到了这样的 sql:

SELECT * FROM `t_box_file_57` WHERE (owner = 57 AND parent_id = 0 AND name like 'New Folder%') AND `t_box_file`.`deleted_at` = 0

后面的表名没有被替换掉。

我只能临时添加了这一行来解决这个问题:

stQuery = strings.ReplaceAll(stQuery, "`"+tableName+"`.", "`"+newTable.Name.Name+"`.")