Skip to content

[TypedMongo] Allowing the discriminator field at any position #411

Closed
@pulewicz

Description

@pulewicz

What is the easiest way of reading class hierarchies with discriminator fields at the end of the object? Unfortunately, we need to adapt to an existing schema.

As explained in https://github.com/AVSystem/scala-commons/blob/master/docs/GenCodec.md#flat-sealed-hierarchy-format:

It may also be sensitive to object field order because the discriminator field must be read before any other fields (this is only a problem with Input implementations that do not support random field access by name - JsonStringInput does not have this problem).

I did some checks, and it seems like BsonReaderInput has this problem, but BsonValueInput hasn't: https://github.com/pulewicz/mongo-commons-playground/blob/master/src/main/scala/PlaygroundApp.scala#L47

Questions:

  1. Is there any easy way to use TypedMongoCollection with value input and output? From what I see currently it's hardcoded and it will need creating your own versions of the following classes, is it correct?

  2. Is using the value input and output a good solution, or are there any disadvantages?

Regards,
Paweł Ulewicz.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions