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

Function BoolParenthesis

coderd/rbac/regosql/sqltypes/parens.go:14–25  ·  view source on GitHub ↗

BoolParenthesis wraps the given boolean node in parens. This is useful for grouping and avoiding ambiguity. This does not work for mathematical parenthesis to change order of operations.

(value BooleanNode)

Source from the content-addressed store, hash-verified

12// This is useful for grouping and avoiding ambiguity. This does not work for
13// mathematical parenthesis to change order of operations.
14func BoolParenthesis(value BooleanNode) BooleanNode {
15 // Wrapping primitives is useless.
16 if IsPrimitive(value) {
17 return value
18 }
19
20 // Unwrap any existing parens. Do not add excess parens.
21 if p, ok := value.(astParenthesis); ok {
22 return BoolParenthesis(p.Value)
23 }
24 return astParenthesis{Value: value}
25}
26
27func (astParenthesis) IsBooleanNode() {}
28func (p astParenthesis) UseAs() Node { return p.Value.UseAs() }

Callers 4

ConvertRegoAstFunction · 0.92
convertCallFunction · 0.92
boolEqualsSQLStringFunction · 0.85
newBinaryOpFunction · 0.85

Calls 1

IsPrimitiveFunction · 0.85

Tested by

no test coverage detected