bchavez / RethinkDb.Driver

:headphones: A NoSQL C#/.NET RethinkDB database driver with 100% ReQL API coverage.
http://rethinkdb.com/api/java
Other
383 stars 134 forks source link

Polymorphism #160

Closed DrewRidley closed 3 years ago

DrewRidley commented 3 years ago

Context

Plain and simple; polymorphic types don't play nicely with the existing RunAtom<T> feature. Not to say they don't play nicely, but in cases where you want a List<MyInheritedType, the entire list is returned as the base class, potentially meaning the loss of all of the fields on that object.

Alternatives

None afaik, other than manually parsing a JObject, and writing a custom serializer to include the type discriminator manually. The best easiest method is using the TypeNameHandling.All argument with the JSON serializer, although this is cited as a potential security risk. Alternatively, the discriminator can be handled manually by RethinkDB and the possibility of ensuring that the discriminator matches the base type of the argument.

If the feature request is approved, would you be willing to submit a PR?

Yes, most likely happy to submit a PR once I understand the scope of the problem, but a quick review before accepting the PR is advised. Also a little new to Unit Testing

DrewRidley commented 3 years ago

It turns out the solution is just enabling TypeNameHandling on the static serializer that the driver uses. No changes are necessary.