Describe the feature

I think it would be more logical to use NOW() check for deleted_at field instead of NULL only check

SELECT ... WHERE ... AND (deleted_at IS NULL OR deleted_at > NOW())

Motivation

In this case deleted_at field can be used as TTL for table row. For example, I need a table row for 1 day only. I can create it:

INSERT INTO table (created_at, deleted_at) VALUES (NOW(), NOW() + INTERVAL('1 day'))

then this row will exists in all SELECT requests while deleted_at > NOW()

PS sorry for my bad english. I hope you can understand me

Related Issues

Comment From: oxyii

something like this

diff --git a/soft_delete.go b/soft_delete.go
index 6d6462880..07dd7d2d7 100644
--- a/soft_delete.go
+++ b/soft_delete.go
@@ -78,7 +78,10 @@ func (sd SoftDeleteQueryClause) ModifyStatement(stmt *Statement) {
        }

        stmt.AddClause(clause.Where{Exprs: []clause.Expression{
-           clause.Eq{Column: clause.Column{Table: clause.CurrentTable, Name: sd.Field.DBName}, Value: nil},
+           clause.Or(
+               clause.Eq{Column: clause.Column{Table: clause.CurrentTable, Name: sd.Field.DBName}, Value: nil},
+               clause.Gt{Column: clause.Column{Table: clause.CurrentTable, Name: sd.Field.DBName}, Value: stmt.DB.NowFunc()},
+           ),
        }})
        stmt.Clauses["soft_delete_enabled"] = clause.Clause{}
    }

Comment From: a631807682

They are only associated by Interface, just define your CustomSoftDeleteClause and CustomDeletedAt to do that,。

Comment From: jinzhu

Hello @oxyii

Not going to support this in GORM to make sure don't hurt performance by default. but glad to accept contributions as a plugin.

Thank you.