From 2ad03285f12a0b6bd8f3baf25a819f90adabbd59 Mon Sep 17 00:00:00 2001 From: Livio Amstutz Date: Mon, 6 Dec 2021 17:22:59 +0100 Subject: [PATCH] fix: user projection (#2795) * fix: first- and lastname changes on user * add reset migration --- internal/query/projection/user.go | 12 ++++++++---- .../cockroach/V1.99__reset_user_projections.sql | 2 ++ 2 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 migrations/cockroach/V1.99__reset_user_projections.sql diff --git a/internal/query/projection/user.go b/internal/query/projection/user.go index 791997528b..dd8cde6d7b 100644 --- a/internal/query/projection/user.go +++ b/internal/query/projection/user.go @@ -5,6 +5,7 @@ import ( "database/sql" "github.com/caos/logging" + "github.com/caos/zitadel/internal/domain" "github.com/caos/zitadel/internal/errors" "github.com/caos/zitadel/internal/eventstore" @@ -379,10 +380,13 @@ func (p *UserProjection) reduceHumanProfileChanged(event eventstore.EventReader) return nil, errors.ThrowInvalidArgument(nil, "HANDL-769v4", "reduce.wrong.event.type") } cols := make([]handler.Column, 0, 6) - cols = append(cols, - handler.NewCol(HumanFistNameCol, e.FirstName), - handler.NewCol(HumanLastNameCol, e.LastName), - ) + if e.FirstName != "" { + cols = append(cols, handler.NewCol(HumanFistNameCol, e.FirstName)) + } + + if e.LastName != "" { + cols = append(cols, handler.NewCol(HumanLastNameCol, e.LastName)) + } if e.NickName != nil { cols = append(cols, handler.NewCol(HumanNickNameCol, *e.NickName)) diff --git a/migrations/cockroach/V1.99__reset_user_projections.sql b/migrations/cockroach/V1.99__reset_user_projections.sql new file mode 100644 index 0000000000..0e7ed009b4 --- /dev/null +++ b/migrations/cockroach/V1.99__reset_user_projections.sql @@ -0,0 +1,2 @@ +truncate zitadel.projections.users cascade; +update zitadel.projections.current_sequences set current_sequence = 0 where projection_name = 'zitadel.projections.users';