diff --git a/engine.go b/engine.go index 81eae28a..f5e61bed 100644 --- a/engine.go +++ b/engine.go @@ -777,6 +777,8 @@ func (engine *Engine) mapType(v reflect.Value) *core.Table { col.Default = "1" case k == "UPDATED": col.IsUpdated = true + case k == "DELETED": + col.IsDeleted = true case strings.HasPrefix(k, "INDEX(") && strings.HasSuffix(k, ")"): indexName := k[len("INDEX")+1 : len(k)-1] indexNames[indexName] = core.IndexType @@ -797,8 +799,6 @@ func (engine *Engine) mapType(v reflect.Value) *core.Table { if !hasNoCacheTag { hasNoCacheTag = true } - case k == "SOFTDELETE": - col.IsSoftDelete = true case k == "NOT": default: if strings.HasPrefix(k, "'") && strings.HasSuffix(k, "'") { diff --git a/session.go b/session.go index c6002b5c..84a02eee 100644 --- a/session.go +++ b/session.go @@ -3404,7 +3404,7 @@ func (session *Session) Delete(bean interface{}) (int64, error) { sqlStr, sqlStrForCache := "", "" argsForCache := make([]interface{}, 0, len(args) * 2) - if session.Engine.unscoped || table.SoftDeleteColumn() == nil { // softdelete is disabled + if session.Engine.unscoped || table.DeletedColumn() == nil { // deleted is disabled sqlStr = fmt.Sprintf("DELETE FROM %v WHERE %v", session.Engine.Quote(session.Statement.TableName()), condition) @@ -3418,17 +3418,17 @@ func (session *Session) Delete(bean interface{}) (int64, error) { copy(argsForCache, args) argsForCache = append(session.Statement.Params, argsForCache...) - softDeleteCol := table.SoftDeleteColumn() + deletedColumn := table.DeletedColumn() sqlStr = fmt.Sprintf("UPDATE %v SET %v = ? WHERE %v", session.Engine.Quote(session.Statement.TableName()), - session.Engine.Quote(softDeleteCol.Name), + session.Engine.Quote(deletedColumn.Name), condition) // !oinume! Insert NowTime to the head of session.Statement.Params session.Statement.Params = append(session.Statement.Params, "") paramsLen := len(session.Statement.Params) copy(session.Statement.Params[1:paramsLen], session.Statement.Params[0:paramsLen-1]) - session.Statement.Params[0] = session.Engine.NowTime(softDeleteCol.SQLType.Name) + session.Statement.Params[0] = session.Engine.NowTime(deletedColumn.SQLType.Name) } args = append(session.Statement.Params, args...) @@ -3677,7 +3677,7 @@ func genCols(table *core.Table, session *Session, bean interface{}, useCol bool, } } - if col.IsSoftDelete { + if col.IsDeleted { continue } diff --git a/statement.go b/statement.go index ade939f5..bb28c651 100644 --- a/statement.go +++ b/statement.go @@ -286,7 +286,7 @@ func buildUpdates(engine *Engine, table *core.Table, bean interface{}, if !includeAutoIncr && col.IsAutoIncrement { continue } - if col.IsSoftDelete { + if col.IsDeleted { continue } @@ -493,7 +493,7 @@ func buildConditions(engine *Engine, table *core.Table, bean interface{}, continue } - if col.IsSoftDelete && !engine.unscoped { // softdelete enabled + if col.IsDeleted && !engine.unscoped { // deleted enabled colNames = append(colNames, fmt.Sprintf("%v IS NULL", engine.Quote(col.Name))) }