fix: save not use soft_delete
This commit is contained in:
		
							parent
							
								
									d98390243a
								
							
						
					
					
						commit
						59770f0cda
					
				@ -57,7 +57,7 @@ func Create(config *Config) func(db *gorm.DB) {
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if db.Statement.SQL.String() == "" {
 | 
							if db.Statement.SQL.Len() == 0 {
 | 
				
			||||||
			db.Statement.SQL.Grow(180)
 | 
								db.Statement.SQL.Grow(180)
 | 
				
			||||||
			db.Statement.AddClauseIfNotExists(clause.Insert{})
 | 
								db.Statement.AddClauseIfNotExists(clause.Insert{})
 | 
				
			||||||
			db.Statement.AddClause(ConvertToCreateValues(db.Statement))
 | 
								db.Statement.AddClause(ConvertToCreateValues(db.Statement))
 | 
				
			||||||
 | 
				
			|||||||
@ -118,13 +118,7 @@ func Delete(config *Config) func(db *gorm.DB) {
 | 
				
			|||||||
			return
 | 
								return
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if db.Statement.Schema != nil {
 | 
							if db.Statement.SQL.Len() == 0 {
 | 
				
			||||||
			for _, c := range db.Statement.Schema.DeleteClauses {
 | 
					 | 
				
			||||||
				db.Statement.AddClause(c)
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		if db.Statement.SQL.String() == "" {
 | 
					 | 
				
			||||||
			db.Statement.SQL.Grow(100)
 | 
								db.Statement.SQL.Grow(100)
 | 
				
			||||||
			db.Statement.AddClauseIfNotExists(clause.Delete{})
 | 
								db.Statement.AddClauseIfNotExists(clause.Delete{})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -147,6 +141,15 @@ func Delete(config *Config) func(db *gorm.DB) {
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			db.Statement.AddClauseIfNotExists(clause.From{})
 | 
								db.Statement.AddClauseIfNotExists(clause.From{})
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if db.Statement.Schema != nil {
 | 
				
			||||||
 | 
								for _, c := range db.Statement.Schema.DeleteClauses {
 | 
				
			||||||
 | 
									db.Statement.AddClause(c)
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if db.Statement.SQL.Len() == 0 {
 | 
				
			||||||
			db.Statement.Build(db.Statement.BuildClauses...)
 | 
								db.Statement.Build(db.Statement.BuildClauses...)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -33,7 +33,7 @@ func BuildQuerySQL(db *gorm.DB) {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if db.Statement.SQL.String() == "" {
 | 
						if db.Statement.SQL.Len() == 0 {
 | 
				
			||||||
		db.Statement.SQL.Grow(100)
 | 
							db.Statement.SQL.Grow(100)
 | 
				
			||||||
		clauseSelect := clause.Select{Distinct: db.Statement.Distinct}
 | 
							clauseSelect := clause.Select{Distinct: db.Statement.Distinct}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -59,7 +59,7 @@ func Update(config *Config) func(db *gorm.DB) {
 | 
				
			|||||||
			return
 | 
								return
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if db.Statement.SQL.String() == "" {
 | 
							if db.Statement.SQL.Len() == 0 {
 | 
				
			||||||
			db.Statement.SQL.Grow(180)
 | 
								db.Statement.SQL.Grow(180)
 | 
				
			||||||
			db.Statement.AddClauseIfNotExists(clause.Update{})
 | 
								db.Statement.AddClauseIfNotExists(clause.Update{})
 | 
				
			||||||
			if set := ConvertToAssignments(db.Statement); len(set) != 0 {
 | 
								if set := ConvertToAssignments(db.Statement); len(set) != 0 {
 | 
				
			||||||
 | 
				
			|||||||
@ -103,7 +103,7 @@ func (sd SoftDeleteUpdateClause) MergeClause(*clause.Clause) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (sd SoftDeleteUpdateClause) ModifyStatement(stmt *Statement) {
 | 
					func (sd SoftDeleteUpdateClause) ModifyStatement(stmt *Statement) {
 | 
				
			||||||
	if stmt.SQL.String() == "" && !stmt.Statement.Unscoped {
 | 
						if stmt.SQL.Len() == 0 && !stmt.Statement.Unscoped {
 | 
				
			||||||
		if _, ok := stmt.Clauses["WHERE"]; stmt.DB.AllowGlobalUpdate || ok {
 | 
							if _, ok := stmt.Clauses["WHERE"]; stmt.DB.AllowGlobalUpdate || ok {
 | 
				
			||||||
			SoftDeleteQueryClause(sd).ModifyStatement(stmt)
 | 
								SoftDeleteQueryClause(sd).ModifyStatement(stmt)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@ -129,7 +129,7 @@ func (sd SoftDeleteDeleteClause) MergeClause(*clause.Clause) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (sd SoftDeleteDeleteClause) ModifyStatement(stmt *Statement) {
 | 
					func (sd SoftDeleteDeleteClause) ModifyStatement(stmt *Statement) {
 | 
				
			||||||
	if stmt.SQL.String() == "" && !stmt.Statement.Unscoped {
 | 
						if stmt.SQL.Len() == 0 && !stmt.Statement.Unscoped {
 | 
				
			||||||
		curTime := stmt.DB.NowFunc()
 | 
							curTime := stmt.DB.NowFunc()
 | 
				
			||||||
		stmt.AddClause(clause.Set{{Column: clause.Column{Name: sd.Field.DBName}, Value: curTime}})
 | 
							stmt.AddClause(clause.Set{{Column: clause.Column{Name: sd.Field.DBName}, Value: curTime}})
 | 
				
			||||||
		stmt.SetColumn(sd.Field.DBName, curTime, true)
 | 
							stmt.SetColumn(sd.Field.DBName, curTime, true)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user