From ba697e7bdf11e943aa9a22002763ae89dbba441a Mon Sep 17 00:00:00 2001 From: Iraq Jaber Date: Fri, 8 Aug 2025 17:05:46 +0100 Subject: [PATCH] fixup! fix(projections): added check to make sure there cannot be 2 projections for the same table --- internal/query/projection/projection.go | 5 +++-- internal/query/query.go | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/internal/query/projection/projection.go b/internal/query/projection/projection.go index 6afe658cc3..c1dd96c95b 100644 --- a/internal/query/projection/projection.go +++ b/internal/query/projection/projection.go @@ -209,17 +209,18 @@ func Init(ctx context.Context) error { return nil } -func Start(ctx context.Context) { +func Start(ctx context.Context) error { projectionTableMap := make(map[string]bool, len(projections)) for _, projection := range projections { table := projection.String() if projectionTableMap[table] { - panic("projeciton for " + projection.String() + " already added") + return fmt.Errorf("projeciton for %s already added", table) } projectionTableMap[table] = true projection.Start(ctx) } + return nil } func ProjectInstance(ctx context.Context) error { diff --git a/internal/query/query.go b/internal/query/query.go index e2e7f58ffc..7be38c6bda 100644 --- a/internal/query/query.go +++ b/internal/query/query.go @@ -90,7 +90,10 @@ func StartQueries( return nil, err } if startProjections { - projection.Start(ctx) + err = projection.Start(ctx) + if err != nil { + return nil, err + } } repo.caches, err = startCaches(