MCPcopy Index your code
hub / github.com/coder/coder / newBinaryOp

Function newBinaryOp

coderd/rbac/regosql/sqltypes/binary.go:35–56  ·  view source on GitHub ↗
(source RegoSource, op binaryOperator, terms ...BooleanNode)

Source from the content-addressed store, hash-verified

33}
34
35func 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
58func (b binaryOp) SQLString(cfg *SQLGenerator) string {
59 sqlOp := ""

Callers 2

OrFunction · 0.85
AndFunction · 0.85

Calls 2

BoolFunction · 0.85
BoolParenthesisFunction · 0.85

Tested by

no test coverage detected