From 0b3bcbd3ec2f335e8b101cdcafaba93fe8d149cc Mon Sep 17 00:00:00 2001 From: Ming Deng Date: Tue, 10 Nov 2020 23:30:24 +0800 Subject: [PATCH] Fix 4298 --- client/orm/orm_conds.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/client/orm/orm_conds.go b/client/orm/orm_conds.go index f3fd66f0..b4e1ce7a 100644 --- a/client/orm/orm_conds.go +++ b/client/orm/orm_conds.go @@ -76,10 +76,13 @@ func (c Condition) AndNot(expr string, args ...interface{}) *Condition { // AndCond combine a condition to current condition func (c *Condition) AndCond(cond *Condition) *Condition { - c = c.clone() + if c == cond { panic(fmt.Errorf(" cannot use self as sub cond")) } + + c = c.clone() + if cond != nil { c.params = append(c.params, condValue{cond: cond, isCond: true}) }