CompileToSQL converts the remaining rego queries into SQL WHERE clauses.
(ctx context.Context, cfg regosql.ConvertConfig)
| 535 | |
| 536 | // CompileToSQL converts the remaining rego queries into SQL WHERE clauses. |
| 537 | func (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 | |
| 553 | func (pa *PartialAuthorizer) Authorize(ctx context.Context, object Object) error { |
| 554 | if pa.alwaysTrue { |