From 9826e1aeb93653de9df049f5aedb5c9a8d32594a Mon Sep 17 00:00:00 2001 From: Jorge Padilla Date: Wed, 13 Sep 2023 16:47:57 -0600 Subject: [PATCH] wip --- server/pkg/sqlutil/tenant.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/server/pkg/sqlutil/tenant.go b/server/pkg/sqlutil/tenant.go index eb9d69ad0e..2a96e3a06e 100644 --- a/server/pkg/sqlutil/tenant.go +++ b/server/pkg/sqlutil/tenant.go @@ -6,6 +6,7 @@ import ( "strings" "github.com/kubeshop/tracetest/server/http/middleware" + "github.com/kubeshop/tracetest/server/pkg/id" ) func Tenant(ctx context.Context, query string, params ...any) (string, []any) { @@ -35,18 +36,17 @@ func TenantWithPrefix(ctx context.Context, query string, prefix string, params . return query + condition, append(params, *tenantID) } -func TenantWithReplacedID(ctx context.Context, query string, params ...any) (string, []any) { +func TenantWithReplacedID(ctx context.Context, query string, id id.ID) (string, []any) { + var params []any tenantID := TenantID(ctx) if tenantID == nil { - return query, params + return query, append(params, id) } prefix := getQueryPrefix(query) - paramNumber := len(params) + 1 - condition := fmt.Sprintf(" %s tenant_id = $%d", prefix, paramNumber) + condition := fmt.Sprintf(" %s tenant_id = $%d", prefix, 2) - var newParams []any - return query + condition, append(newParams, *tenantID, *tenantID) + return query + condition, append(params, *tenantID, *tenantID) } func TenantID(ctx context.Context) *string {