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

Method CompileToSQL

coderd/rbac/authz.go:537–551  ·  view source on GitHub ↗

CompileToSQL converts the remaining rego queries into SQL WHERE clauses.

(ctx context.Context, cfg regosql.ConvertConfig)

Source from the content-addressed store, hash-verified

535
536// CompileToSQL converts the remaining rego queries into SQL WHERE clauses.
537func (pa *PartialAuthorizer) CompileToSQL(ctx context.Context, cfg regosql.ConvertConfig) (string, error) {
538 _, span := tracing.StartSpan(ctx, trace.WithAttributes(
539 // Query count is a rough indicator of the complexity of the query
540 // that needs to be converted into SQL.
541 attribute.Int("query_count", len(pa.preparedQueries)),
542 attribute.Bool("always_true", pa.alwaysTrue),
543 ))
544 defer span.End()
545
546 filter, err := Compile(cfg, pa)
547 if err != nil {
548 return "", xerrors.Errorf("compile: %w", err)
549 }
550 return filter.SQLString(), nil
551}
552
553func (pa *PartialAuthorizer) Authorize(ctx context.Context, object Object) error {
554 if pa.alwaysTrue {

Callers

nothing calls this directly

Calls 5

StartSpanFunction · 0.92
CompileFunction · 0.85
IntMethod · 0.80
SQLStringMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected