(source RegoSource, op binaryOperator, terms ...BooleanNode)
| 33 | } |
| 34 | |
| 35 | func newBinaryOp(source RegoSource, op binaryOperator, terms ...BooleanNode) BooleanNode { |
| 36 | if len(terms) == 0 { |
| 37 | // TODO: How to handle 0 terms? |
| 38 | return Bool(false) |
| 39 | } |
| 40 | |
| 41 | opTerms := make([]BooleanNode, 0, len(terms)) |
| 42 | for i := range terms { |
| 43 | // Always wrap terms in parentheses to be safe. |
| 44 | opTerms = append(opTerms, BoolParenthesis(terms[i])) |
| 45 | } |
| 46 | |
| 47 | if len(opTerms) == 1 { |
| 48 | return opTerms[0] |
| 49 | } |
| 50 | |
| 51 | return binaryOp{ |
| 52 | Terms: opTerms, |
| 53 | op: op, |
| 54 | source: source, |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | func (b binaryOp) SQLString(cfg *SQLGenerator) string { |
| 59 | sqlOp := "" |
no test coverage detected