(ctx context.Context, row RequestRow)
| 68 | } |
| 69 | |
| 70 | func (s *postgresStore) CreateRequest(ctx context.Context, row RequestRow) error { |
| 71 | _, err := s.db.ExecContext(ctx, ` |
| 72 | INSERT INTO requests ( |
| 73 | request_id, trace_id, request_type, tenant_id, task_type, priority, pipeline_ref, |
| 74 | input_json, context_json, ai_request_json, policy_snapshot_json, status, selected_backend, route_reason, |
| 75 | created_at, updated_at |
| 76 | ) VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16)`, |
| 77 | row.RequestID, row.TraceID, row.RequestType, row.TenantID, row.TaskType, row.Priority, row.PipelineRef, |
| 78 | string(row.InputJSON), string(row.ContextJSON), nullIfEmpty(row.AIRequestJSON), string(row.PolicySnapshot), row.Status, row.SelectedBackend, row.RouteReason, |
| 79 | row.CreatedAt.UnixMilli(), row.UpdatedAt.UnixMilli(), |
| 80 | ) |
| 81 | return err |
| 82 | } |
| 83 | |
| 84 | func nullIfEmpty(b []byte) interface{} { |
| 85 | if len(b) == 0 { |
nothing calls this directly
no test coverage detected