You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
google-cloud-firestore Extension point to serialize pojo to map #2579
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
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.
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.
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.
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?
Activity
anthmgoogle commentedon Nov 8, 2017
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.
schmidt-sebastian commentedon Nov 9, 2017
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.
schmidt-sebastian commentedon Nov 16, 2017
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.
hienle-hps commentedon Jan 17, 2019
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
CustomClassMapperwhoseBeanMapperandmapperregistry already seem suitable for user-extension. Were there concerns about bloating the main Firestore library with a complex ORM API?chore(main): release 2.38.1-SNAPSHOT (#2579)
chore(main): release 2.40.1-SNAPSHOT (#2579)
chore(deps): update dependency com.google.cloud:google-cloud-pubsub t…
chore(deps): update dependency com.google.cloud:google-cloud-pubsub t…
fix: use service name as the default audience (googleapis#2579)
chore(main): release 2.58.2 (googleapis#2575)