Skip to content

Commit

Permalink
modify unscoped judge (go-gorm#4929)
Browse files Browse the repository at this point in the history
* modify unscoped judge

* modify unscoped judge

Co-authored-by: liweiting <[email protected]>
  • Loading branch information
liweitingwt and liweiting authored Dec 16, 2021
1 parent adf8f70 commit 24026bf
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion callbacks/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func Query(db *gorm.DB) {
}

func BuildQuerySQL(db *gorm.DB) {
if db.Statement.Schema != nil && !db.Statement.Unscoped {
if db.Statement.Schema != nil {
for _, c := range db.Statement.Schema.QueryClauses {
db.Statement.AddClause(c)
}
Expand Down
2 changes: 1 addition & 1 deletion soft_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (sd SoftDeleteQueryClause) MergeClause(*clause.Clause) {
}

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

0 comments on commit 24026bf

Please sign in to comment.