(builder Builder)
| 166 | } |
| 167 | |
| 168 | func (not NotConditions) Build(builder Builder) { |
| 169 | anyNegationBuilder := false |
| 170 | for _, c := range not.Exprs { |
| 171 | if _, ok := c.(NegationExpressionBuilder); ok { |
| 172 | anyNegationBuilder = true |
| 173 | break |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | if anyNegationBuilder { |
| 178 | if len(not.Exprs) > 1 { |
| 179 | builder.WriteByte('(') |
| 180 | } |
| 181 | |
| 182 | for idx, c := range not.Exprs { |
| 183 | if idx > 0 { |
| 184 | builder.WriteString(AndWithSpace) |
| 185 | } |
| 186 | |
| 187 | if negationBuilder, ok := c.(NegationExpressionBuilder); ok { |
| 188 | negationBuilder.NegationBuild(builder) |
| 189 | } else { |
| 190 | builder.WriteString("NOT ") |
| 191 | e, wrapInParentheses := c.(Expr) |
| 192 | if wrapInParentheses { |
| 193 | sql := strings.ToUpper(e.SQL) |
| 194 | if wrapInParentheses = strings.Contains(sql, AndWithSpace) || strings.Contains(sql, OrWithSpace); wrapInParentheses { |
| 195 | builder.WriteByte('(') |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | c.Build(builder) |
| 200 | |
| 201 | if wrapInParentheses { |
| 202 | builder.WriteByte(')') |
| 203 | } |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | if len(not.Exprs) > 1 { |
| 208 | builder.WriteByte(')') |
| 209 | } |
| 210 | } else { |
| 211 | builder.WriteString("NOT ") |
| 212 | if len(not.Exprs) > 1 { |
| 213 | builder.WriteByte('(') |
| 214 | } |
| 215 | |
| 216 | for idx, c := range not.Exprs { |
| 217 | if idx > 0 { |
| 218 | switch c.(type) { |
| 219 | case OrConditions: |
| 220 | builder.WriteString(OrWithSpace) |
| 221 | default: |
| 222 | builder.WriteString(AndWithSpace) |
| 223 | } |
| 224 | } |
| 225 |
nothing calls this directly
no test coverage detected