From 8278efc131e3d6286fd16aebe59b416da1be6e19 Mon Sep 17 00:00:00 2001 From: Silvan Date: Tue, 6 Oct 2020 07:26:09 +0200 Subject: [PATCH] fix(eventstore): check if creation date is not zero (#811) --- internal/eventstore/internal/repository/sql/push.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/eventstore/internal/repository/sql/push.go b/internal/eventstore/internal/repository/sql/push.go index 16657a407e..2795a5c89f 100644 --- a/internal/eventstore/internal/repository/sql/push.go +++ b/internal/eventstore/internal/repository/sql/push.go @@ -68,7 +68,8 @@ func precondtion(tx *sql.Tx, aggregate *models.Aggregate) error { func insertEvents(stmt *sql.Stmt, previousSequence Sequence, events []*models.Event) error { for _, event := range events { - err := stmt.QueryRow(event.Type, event.AggregateType, event.AggregateID, event.AggregateVersion, event.CreationDate, Data(event.Data), event.EditorUser, event.EditorService, event.ResourceOwner, previousSequence, + creationDate := sql.NullTime{Time: event.CreationDate, Valid: !event.CreationDate.IsZero()} + err := stmt.QueryRow(event.Type, event.AggregateType, event.AggregateID, event.AggregateVersion, creationDate, Data(event.Data), event.EditorUser, event.EditorService, event.ResourceOwner, previousSequence, event.AggregateType, event.AggregateID, previousSequence, previousSequence).Scan(&previousSequence, &event.CreationDate) if err != nil {