forked from mirror/gorm
modify unscoped judge (#4929)
* modify unscoped judge * modify unscoped judge Co-authored-by: liweiting <liweiting1995@gmail.com>
This commit is contained in:
parent
adf8f70f06
commit
24026bf1fe
|
@ -27,7 +27,7 @@ func Query(db *gorm.DB) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func BuildQuerySQL(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 {
|
for _, c := range db.Statement.Schema.QueryClauses {
|
||||||
db.Statement.AddClause(c)
|
db.Statement.AddClause(c)
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ func (sd SoftDeleteQueryClause) MergeClause(*clause.Clause) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sd SoftDeleteQueryClause) ModifyStatement(stmt *Statement) {
|
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 c, ok := stmt.Clauses["WHERE"]; ok {
|
||||||
if where, ok := c.Expression.(clause.Where); ok && len(where.Exprs) > 1 {
|
if where, ok := c.Expression.(clause.Where); ok && len(where.Exprs) > 1 {
|
||||||
for _, expr := range where.Exprs {
|
for _, expr := range where.Exprs {
|
||||||
|
|
Loading…
Reference in New Issue