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

Wrong type of event's timestamp when using some mappers #729

Closed
mpraglowski opened this issue May 5, 2020 · 4 comments
Closed

Wrong type of event's timestamp when using some mappers #729

mpraglowski opened this issue May 5, 2020 · 4 comments
Assignees
Labels

Comments

@mpraglowski
Copy link
Member

When using RubyEventStore::Event class it is expected that metadata should be either Time instance or nil (see https://github.com/RailsEventStore/rails_event_store/blob/master/ruby_event_store/lib/ruby_event_store/event.rb#L39 ) and that works for default setup (mapper):

store = RubyEventStore::InMemoryRepository.new
mapper = RubyEventStore::Mappers::Default.new
es = RubyEventStore::Client.new(repository: store, mapper: mapper)
FooEvent = Class.new(RubyEventStore::Event)
es.publish(FooEvent.new(data: {some: :value}))
es.read.last.timestamp.class
# => Time

but timestamp is String when using JSON serializer:

store = RubyEventStore::InMemoryRepository.new
mapper = RubyEventStore::Mappers::Default.new(serializer: JSON)
es = RubyEventStore::Client.new(repository: store, mapper: mapper)
FooEvent = Class.new(RubyEventStore::Event)
es.publish(FooEvent.new(data: {some: :value}))
es.read.last.timestamp.class
# => String
@mpraglowski mpraglowski added the bug label May 5, 2020
@mostlyobvious
Copy link
Member

Why would we allow nil?

@mostlyobvious
Copy link
Member

mostlyobvious commented May 5, 2020

Does the bug exist in #674 as well?

@mpraglowski
Copy link
Member Author

Why would we allow nil?

because not published events does not have a timestamp:

FooEvent.new.timestamp
# => nil

mpraglowski added a commit that referenced this issue Sep 8, 2020
@mostlyobvious mostlyobvious self-assigned this Sep 18, 2020
@mostlyobvious
Copy link
Member

No longer a case after merging #674:

mapper = RubyEventStore::Mappers::Default.new
store = RubyEventStore::InMemoryRepository.new(serializer: JSON)
es = RubyEventStore::Client.new(repository: store, mapper: mapper)
FooEvent = Class.new(RubyEventStore::Event)
es.publish(FooEvent.new(data: {some: :value}))
es.read.last.timestamp.class
=> Time

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

No branches or pull requests

2 participants