NEventStore / NEventStore.Persistence.MongoDB

Mongo Persistence Engine for NEventStore
MIT License
22 stars 26 forks source link

IDocumentSerializer and its usage is flawed #42

Open AGiorgetti opened 8 years ago

AGiorgetti commented 8 years ago

There's a problem in how the thing is used to implement custom serialization of the events in a commit which impacts the database schema that is generated.

This interface is also used in different ways in each driver implementation and this should be documented

The original implementation did:

new BsonDocumentWrapper(typeof (EventMessage), serializer.Serialize(e))

which implied that the output of a serializer.Serialize method should have been something derived from EventMessage, but this wasn't evident from the documentation.

The actual implementation on develop does:

new BsonDocumentWrapper(serializer.Serialize(e))

there's no more nominal type usage anymore, so there's no more implicit inheritance of the object that will be serialized inside the payload, this will cause schema differences, because mongodb c# driver is now adding a "_t" attribute to each serialized object.

We should define correct usage of this interface, which IMO should be (to keep compatibility with the past):

otherwise we can go for having a 'private' EventMessage-like class in the driver that we'll use to keep schema compatibility.

AGiorgetti commented 8 years ago

In the meanwhile I think the right thing to do is to revert to the original way of serializing an EventMessage using the explicit nominal type.