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

Function boolEqualsSQLString

coderd/rbac/regosql/sqltypes/equality.go:71–88  ·  view source on GitHub ↗
(cfg *SQLGenerator, a BooleanNode, not bool, other Node)

Source from the content-addressed store, hash-verified

69}
70
71func boolEqualsSQLString(cfg *SQLGenerator, a BooleanNode, not bool, other Node) (string, error) {
72 switch other.UseAs().(type) {
73 case BooleanNode:
74 bn, ok := other.(BooleanNode)
75 if !ok {
76 return "", xerrors.Errorf("not a boolean node: %T", other)
77 }
78
79 // Always wrap both sides in parens to ensure the correct precedence.
80 return fmt.Sprintf("%s %s %s",
81 BoolParenthesis(a).SQLString(cfg),
82 equalsOp(not),
83 BoolParenthesis(bn).SQLString(cfg),
84 ), nil
85 default:
86 return "", xerrors.Errorf("unsupported equality: %T %s %T", a, equalsOp(not), other)
87 }
88}
89
90// nolint:revive
91func equalsOp(not bool) string {

Callers 3

EqualsSQLStringMethod · 0.85
EqualsSQLStringMethod · 0.85
EqualsSQLStringMethod · 0.85

Calls 5

BoolParenthesisFunction · 0.85
equalsOpFunction · 0.85
UseAsMethod · 0.65
SQLStringMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected