From eaaf76a6eb519a6583c6e70a1f5617f5a67967f6 Mon Sep 17 00:00:00 2001 From: Fabi <38692350+fgerschwiler@users.noreply.github.com> Date: Wed, 19 Jan 2022 15:13:04 +0100 Subject: [PATCH] fix: default message text query (#3064) --- internal/query/message_text.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/internal/query/message_text.go b/internal/query/message_text.go index 44d82258f4..6c9edb8668 100644 --- a/internal/query/message_text.go +++ b/internal/query/message_text.go @@ -168,13 +168,8 @@ func (q *Queries) CustomMessageTextByTypeAndLanguage(ctx context.Context, aggreg sq.Eq{ MessageTextColType.identifier(): messageType, }, - sq.Or{ - sq.Eq{ - MessageTextColAggregateID.identifier(): aggregateID, - }, - sq.Eq{ - MessageTextColAggregateID.identifier(): domain.IAMID, - }, + sq.Eq{ + MessageTextColAggregateID.identifier(): aggregateID, }, }, ). @@ -185,7 +180,11 @@ func (q *Queries) CustomMessageTextByTypeAndLanguage(ctx context.Context, aggreg } row := q.client.QueryRowContext(ctx, query, args...) - return scan(row) + msg, err := scan(row) + if errors.IsNotFound(err) { + return q.IAMMessageTextByTypeAndLanguage(ctx, messageType, language) + } + return msg, err } func (q *Queries) IAMMessageTextByTypeAndLanguage(ctx context.Context, messageType, language string) (*MessageText, error) { @@ -219,6 +218,7 @@ func (q *Queries) IAMMessageTextByTypeAndLanguage(ctx context.Context, messageTy } result := notificationText.GetMessageTextByType(messageType) result.IsDefault = true + result.AggregateID = domain.IAMID return result, nil }