From 1f2355b1bffa9646083cfbaa39c7ce208a644602 Mon Sep 17 00:00:00 2001 From: TossPig Date: Sun, 23 Nov 2014 17:58:09 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9IsDeleted=E7=9A=84?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在pqsql下测试通过 --- statement.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/statement.go b/statement.go index b19b2b8b..3f063140 100644 --- a/statement.go +++ b/statement.go @@ -507,7 +507,7 @@ func buildConditions(engine *Engine, table *core.Table, bean interface{}, } if col.IsDeleted && !unscoped { // tag "deleted" is enabled - colNames = append(colNames, fmt.Sprintf("%v IS NULL", engine.Quote(col.Name))) + colNames = append(colNames, fmt.Sprintf("(%v IS NULL or %v = '0001-01-01 00:00:00') ", engine.Quote(col.Name), engine.Quote(col.Name))) } fieldValue := *fieldValuePtr From f75f91bfe07c8f9fd4e6ebb8c97faebbfd622efa Mon Sep 17 00:00:00 2001 From: TossPig Date: Sun, 23 Nov 2014 17:59:10 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9IsDeleted=E7=9A=84?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在pqsql下测试通过 --- session.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/session.go b/session.go index 7b4e6690..e5ec7fd0 100644 --- a/session.go +++ b/session.go @@ -1145,7 +1145,7 @@ func (session *Session) Find(rowsSlicePtr interface{}, condiBean ...interface{}) // See https://github.com/go-xorm/xorm/issues/179 for _, col := range table.Columns() { if col.IsDeleted && !session.Statement.unscoped { // tag "deleted" is enabled - session.Statement.ConditionStr = fmt.Sprintf("%v IS NULL", session.Engine.Quote(col.Name)) + session.Statement.ConditionStr = fmt.Sprintf("(%v IS NULL or %v = '0001-01-01 00:00:00') ", session.Engine.Quote(col.Name), session.Engine.Quote(col.Name)) } } } From 60d11ae8c16673b3f48d361a72521bc898b12526 Mon Sep 17 00:00:00 2001 From: TossPig Date: Sun, 23 Nov 2014 18:04:22 +0800 Subject: [PATCH 3/3] fmt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 多了个空格。。。 --- statement.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/statement.go b/statement.go index 3f063140..6c586ae6 100644 --- a/statement.go +++ b/statement.go @@ -507,7 +507,7 @@ func buildConditions(engine *Engine, table *core.Table, bean interface{}, } if col.IsDeleted && !unscoped { // tag "deleted" is enabled - colNames = append(colNames, fmt.Sprintf("(%v IS NULL or %v = '0001-01-01 00:00:00') ", engine.Quote(col.Name), engine.Quote(col.Name))) + colNames = append(colNames, fmt.Sprintf("(%v IS NULL or %v = '0001-01-01 00:00:00')", engine.Quote(col.Name), engine.Quote(col.Name))) } fieldValue := *fieldValuePtr