Skip to content

连表的时候右边软删除字段没生效 #883

Closed
@huyangcheng

Description

@huyangcheng

逻辑删除采用的是 0/1,A B表单表查询软删除都生效的

IsDeleted soft_delete.DeletedAt gorm:"column:is_deleted;softDelete:flag" json:"isDeleted" // 逻辑删除

联表的代码(现在联调右表被删除的字段也被查询出来了)
qc := dao.Q.WithContext(d.ctx) qc.A.Join(dao.B, dao.B.DatasourceID.EqCol(dao.A.ID)).Where(conds...).Find()

并且 dao.DatasourcePermission.IsDeleted.Eq 需要传递是参数类型为 driver.Valuer
我现在不知道怎么创建 0/1 的driver.Valuer 变量

临时解决办法,把B表的 isDelete = A 表的 isDelete 并加入到 conds 中
dao.B.IsDeleted.EqCol(dao.A.IsDeleted)

请求各位设置右表 isDeleted = 0 或者默认让右表软删除字段生效

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions