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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: resolve serialization errors in .NET examples #37

Merged
merged 1 commit into from Sep 26, 2023

Conversation

moonshxne
Copy link
Contributor

@moonshxne moonshxne commented Sep 23, 2023

This ended up being a slightly bigger commit than I anticipated. But, I essentially did two things:

  • Annotate all *Result types in Mondocks.Net/Types.fs with [<BsonIgnoreExtraElements>]; otherwise, the .NET MongoDB Driver freaks out that the schema doesn't match exactly.

  • Avoid serializing each Index object in the IndexBuilder. When I first ran the example in samples/Indexes, it failed with this exception:

Unhandled exception. MongoDB.Driver.MongoCommandException: Command createIndexes failed: BSON field 'createIndexes.indexes.0' is the wrong type 'string', expected type 'object'.

So we DON'T need the serialization step in the IndexBuilder anymore (though I kept the interface the same).

Finally, I added a Nix flake with a very simple devShell because that's just what I'm used to developing with 馃槄.

This ended up being a *slightly* bigger commit than I anticipated. But,
I essentially did two things:

- Annotate all `*Result` types in `Mondocks.Net/Types.fs` with
  `[<BsonIgnoreExtraElements>]`; otherwise, the .NET MongoDB Driver
  freaks out that the schema doesn't match exactly.

- Avoid serializing each `Index` object in the `IndexBuilder`.
  When I first ran the example in `samples/Indexes`, it failed with this
  exception:

  ```sh
  Unhandled exception. MongoDB.Driver.MongoCommandException: Command createIndexes failed: BSON field 'createIndexes.indexes.0' is the wrong type 'string', expected type 'object'.
  ```
  So we DON'T need the serialization step in the `IndexBuilder` anymore
  (though I kept the interface the same).

Finally, I added a Nix flake with a very simple `devShell` because
that's just what I'm used to developing with.
@moonshxne
Copy link
Contributor Author

moonshxne commented Sep 23, 2023

Fixes #36.

Copy link
Owner

@AngelMunoz AngelMunoz left a comment

Choose a reason for hiding this comment

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

Over all looks great!

I'm not entirely sure about the nix flake though if you don't mind me pinging you if something weird arises with that it's fine to keep

I'll try to give it a go this week and see how it goes!

@moonshxne
Copy link
Contributor Author

Feel free to ignore/delete the Nix flake if you're not interested 馃槄. I'm not building anything, just providing a very simple devShell that brings dotnet6.0 into the $PATH. (But, if you have any questions, feel free to ping me!)

@AngelMunoz AngelMunoz merged commit ee52d66 into AngelMunoz:main Sep 26, 2023
1 check passed
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.

None yet

2 participants