refactor AndConditions&OrConditions Build method

This commit is contained in:
0x2d3c 2021-03-24 21:24:59 +08:00
parent 26e0c6fb69
commit 01c84fa8e0

View File

@ -102,10 +102,10 @@ type AndConditions struct {
func (and AndConditions) Build(builder Builder) { func (and AndConditions) Build(builder Builder) {
if len(and.Exprs) > 1 { if len(and.Exprs) > 1 {
builder.WriteByte('(') builder.WriteByte('(')
buildExprs(and.Exprs, builder, " AND ") }
buildExprs(and.Exprs, builder, " AND ")
if len(and.Exprs) > 1 {
builder.WriteByte(')') builder.WriteByte(')')
} else {
buildExprs(and.Exprs, builder, " AND ")
} }
} }
@ -123,10 +123,10 @@ type OrConditions struct {
func (or OrConditions) Build(builder Builder) { func (or OrConditions) Build(builder Builder) {
if len(or.Exprs) > 1 { if len(or.Exprs) > 1 {
builder.WriteByte('(') builder.WriteByte('(')
buildExprs(or.Exprs, builder, " OR ") }
buildExprs(or.Exprs, builder, " OR ")
if len(or.Exprs) > 1 {
builder.WriteByte(')') builder.WriteByte(')')
} else {
buildExprs(or.Exprs, builder, " OR ")
} }
} }