Skip to content

Conventions should not affect mongodb serialization #43

Merged
merged 2 commits into from
Nov 20, 2020
Merged

Conventions should not affect mongodb serialization #43

merged 2 commits into from
Nov 20, 2020

Conversation

Tolyandre
Copy link
Contributor

Assume an application that uses Horarium have code like this:

 ConventionRegistry.Register("EnumStringConvention",
                new ConventionPack {new EnumRepresentationConvention(BsonType.String),}, t => true);

Such code can be used to adjust the application's MongoDB document, but accidentally changes Horarium's internal representation of enum Status. Jobs serialized with different conventions are not compatible.

This behavior discovered after #41 lazy MongoDB access. With lazy MongoDB access, the app has time to register conventions. That leads to different serialization with lazy and without lazy access.

PR sets Horarium's field names and types explicitly to always match default conventions.

Also, minor typos fixed.

…t Horarium mongodb serialization. Mongodb fields and types are explicit now.
@codecov-io
Copy link

Codecov Report

Merging #43 (78a1d02) into master (ac23468) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #43   +/-   ##
=======================================
  Coverage   69.85%   69.85%           
=======================================
  Files          32       32           
  Lines         909      909           
=======================================
  Hits          635      635           
  Misses        274      274           
Impacted Files Coverage Δ
src/Horarium.Mongo/JobMongoModel.cs 98.30% <ø> (ø)
src/Horarium.Mongo/RecurrentJobSettingsMongo.cs 0.00% <ø> (ø)
src/Horarium.Mongo/MongoRepositoryFactory.cs 75.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ac23468...78a1d02. Read the comment docs.

Copy link

@uzser uzser left a comment

Choose a reason for hiding this comment

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

Appoved

@Bounz Bounz merged commit e46daa4 into Tinkoff:master Nov 20, 2020
@Tolyandre Tolyandre deleted the mongo-defaults branch November 26, 2020 13:32
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants