From 01c84fa8e03e6deb0fc3212f3e3c32366557a2ff Mon Sep 17 00:00:00 2001 From: 0x2d3c Date: Wed, 24 Mar 2021 21:24:59 +0800 Subject: [PATCH] refactor AndConditions&OrConditions Build method --- clause/where.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/clause/where.go b/clause/where.go index 00b1a40e..1baea839 100644 --- a/clause/where.go +++ b/clause/where.go @@ -102,10 +102,10 @@ type AndConditions struct { func (and AndConditions) Build(builder Builder) { if len(and.Exprs) > 1 { builder.WriteByte('(') - buildExprs(and.Exprs, builder, " AND ") + } + buildExprs(and.Exprs, builder, " AND ") + if len(and.Exprs) > 1 { builder.WriteByte(')') - } else { - buildExprs(and.Exprs, builder, " AND ") } } @@ -123,10 +123,10 @@ type OrConditions struct { func (or OrConditions) Build(builder Builder) { if len(or.Exprs) > 1 { builder.WriteByte('(') - buildExprs(or.Exprs, builder, " OR ") + } + buildExprs(or.Exprs, builder, " OR ") + if len(or.Exprs) > 1 { builder.WriteByte(')') - } else { - buildExprs(or.Exprs, builder, " OR ") } }