Skip to content

Mapping scala BigDecimal to BSON NumberDecimal instead of binary #410

Closed
@pulewicz

Description

@pulewicz

What is the best to map scala.math.BigDecimal to NumberDecimal instead of binary?

I created a repo with this example and currently it looks like that:

case class TypeWithBigDecimal(x: BigDecimal, y: BigDecimal)

TypeWithBigDecimal(x = 103234.42343, y = 12344.423)

{"x": {"$binary": {"base64": "AmdTOqcAAAAF", "subType": "00"}}, "y": {"$binary": {"base64": "ALxcZwAAAAM=", "subType": "00"}}}

https://github.com/pulewicz/mongo-commons-playground/blob/master/src/main/scala/PlaygroundApp.scala#L89

From what I see, this is currently hardcoded in all of of the Bson outputs, so I guess the only way would be to create your own output implementation, isn't it?

https://github.com/AVSystem/scala-commons/blob/master/commons-mongo/jvm/src/main/scala/com/avsystem/commons/mongo/BsonValueOutput.scala#L39
https://github.com/AVSystem/scala-commons/blob/master/commons-mongo/jvm/src/main/scala/com/avsystem/commons/mongo/BsonWriterOutput.scala#L26
https://github.com/AVSystem/scala-commons/blob/master/commons-mongo/jvm/src/main/scala/com/avsystem/commons/mongo/BsonWriterOutput.scala#L63

Are you planning to make it configurable?

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