spring-data-mongodb icon indicating copy to clipboard operation
spring-data-mongodb copied to clipboard

Wrong type definition for Duration due to converter

Open geliotropv opened this issue 3 years ago • 1 comments

When writing a duration type parameter to the database, Spring defines it as a String after using converters, it can be seen that JRS310Converters.DurationToStringConverter is being used, but I need its real type and not a modified one.

Now I have to write a strange converter that is used when writing to the database. I need exactly its type. further it is used for custom codec @WritingConverter class DurationToDurationConverter : Converter<Duration, Duration> { override fun convert(source: Duration): Duration = source }

geliotropv avatar Aug 19 '22 13:08 geliotropv

There's room for improvement regarding custom Codec usage. The types it would need, to influence the ConverterConfiguration by eg. providing a filter that disables registration of default converters, are not visible and the MongoConverterConfigurationAdapter only exposes a very specific subset of what the ConverterConfiguration allows. We'll need to revisit that arrangement to be able to address the issue you describe.

christophstrobl avatar Aug 22 '22 05:08 christophstrobl