Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix events stored with no stream_type #32

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

krzysztofreczek
Copy link
Collaborator

@krzysztofreczek krzysztofreczek commented Feb 3, 2023

This is a bug-fix for #31

The root problem was the fact that when loading events from the DB and creating a new instance of an Entity with stream injected, the stream_type property was ignored. In consequence, a new instance was created with empty stream_type and all of the subsequent events were stored without it.

I run the tests before and after the change and it proves the issue is gone now.
Before
image

After
image

@krzysztofreczek krzysztofreczek linked an issue Feb 3, 2023 that may be closed by this pull request
@@ -35,10 +35,18 @@ type Entity[T any] interface {
// NewEntity instantiates a new T with the given events applied to it.
// At the same time the entity's internal Stream is initialised,
// so it can record new upcoming stream.
func NewEntity[T Entity[T]](id string, eventsSlice []VersionedEvent[T]) (*T, error) {
func NewEntity[T Entity[T]](
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could consider keeping this one and adding NewEntityWithStreamType for easier use when we don't care about the stream type (like in the in-memory repository).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@krzysztofreczek
Copy link
Collaborator Author

@m110, I have fixed the issue you have found and simplified the implementation a little bit. Can you have another look, please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Some events have no stream_type
2 participants