Skip to content

Commit 24026bf

Browse files
liweitingwtliweiting
and
liweiting
authored
modify unscoped judge (#4929)
* modify unscoped judge * modify unscoped judge Co-authored-by: liweiting <liweiting1995@gmail.com>
1 parent adf8f70 commit 24026bf

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

callbacks/query.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func Query(db *gorm.DB) {
2727
}
2828

2929
func BuildQuerySQL(db *gorm.DB) {
30-
if db.Statement.Schema != nil && !db.Statement.Unscoped {
30+
if db.Statement.Schema != nil {
3131
for _, c := range db.Statement.Schema.QueryClauses {
3232
db.Statement.AddClause(c)
3333
}

soft_delete.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func (sd SoftDeleteQueryClause) MergeClause(*clause.Clause) {
6363
}
6464

6565
func (sd SoftDeleteQueryClause) ModifyStatement(stmt *Statement) {
66-
if _, ok := stmt.Clauses["soft_delete_enabled"]; !ok {
66+
if _, ok := stmt.Clauses["soft_delete_enabled"]; !ok && !stmt.Statement.Unscoped {
6767
if c, ok := stmt.Clauses["WHERE"]; ok {
6868
if where, ok := c.Expression.(clause.Where); ok && len(where.Exprs) > 1 {
6969
for _, expr := range where.Exprs {

0 commit comments

Comments
 (0)