Skip to content

google-cloud-firestore Extension point to serialize pojo to map #2579

Closed

Description

@kamaz

Converting custom types like BigDecimal fail with error:

Cannot convert 12.0099999999999997868371792719699442386627197265625 to Firestore Value

Looking through the code couldn't find a way how I could add a custom converter that would allow anyone to do conversion before serialization without creating additional layer that is specific to firestore.

It would be great if one of following could be provided to add ability to apply custom coversions:

  • inject a whole new class mapper (instead of using CustomClassMapper) - but that could potentially be a big ask
  • have a converter annotation similar to @Exclude, @PropertyName that would enable to add converter to CustomClassMapper
  • alternatives?

Activity

  1. added
    api: firestoreIssues related to the Firestore API.
    type: questionRequest for information or clarification. Not an issue.
    on Nov 8, 2017
  2. anthmgoogle commented on Nov 8, 2017

    @anthmgoogle

    We will first confirm whether there is an existing way to do this so making it a question. If there is no current way to do this, we will convert to feature request.

  3. self-assigned this
    on Nov 8, 2017
  4. schmidt-sebastian commented on Nov 9, 2017

    @schmidt-sebastian
    Contributor

    This is currently not possible. For now, you have to convert it manually to one of our supported types.
    We will bring this up for discussion internally.

  5. schmidt-sebastian commented on Nov 16, 2017

    @schmidt-sebastian
    Contributor

    As per our internal discussion, we are not treating this as high priority item for now and suggest that you implement your own serialization at the POJO level. If you give us a Map that has BigDecimals already serialized to a String, you will be able to store these objects in Firestore.

  6. hienle-hps commented on Jan 17, 2019

    @hienle-hps

    Sorry to resurrect an old thread, the POJO to Map recommendation seems reasonable but leaves questions around de-serialization.

    @schmidt-sebastian can you share any details from the internal discussions? Specifically regarding CustomClassMapper whose BeanMapper and mapper registry already seem suitable for user-extension. Were there concerns about bloating the main Firestore library with a complex ORM API?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

api: firestoreIssues related to the Firestore API.type: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions