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
This seems to work fine for columns of type Duration, however it does not work on List<Duration> when that list is an empty list.
When trying to persist an empty list I get the following error:
java.lang.IllegalArgumentException: Cannot encode parameter of type [Ljava.time.Duration; ([Ljava.time.Duration;@45b7445b)
at io.r2dbc.postgresql.codec.DefaultCodecs.encodeParameterValue(DefaultCodecs.java:276)
at io.r2dbc.postgresql.codec.DefaultCodecs.encode(DefaultCodecs.java:250)
at io.r2dbc.postgresql.PostgresqlStatement.bind(PostgresqlStatement.java:107)
This can be tracked down to this part of spring-data-r2dbc:
For collections it first tries to find a common type based on the elements using CollectionUtils.findCommonElementType((Collection<?>) value.getValue()) (which are already converted if there were elements in the array).
This means that for non-empty collections it will correctly use the Interval type, but for empty collections it will actually use converter.getTargetType(actualType), which returns Duration.
Is there a way to get converters to work properly?
Especially since the docs say that per-element converters is the way to go:
Please note that converters get applied on singular properties. Collection properties (e.g. Collection) are iterated and converted element-wise.
The text was updated successfully, but these errors were encountered:
We're using java
Duration
types that get converted toInterval
using Reading/WritingConverters:This seems to work fine for columns of type
Duration
, however it does not work onList<Duration>
when that list is an empty list.When trying to persist an empty list I get the following error:
This can be tracked down to this part of spring-data-r2dbc:
spring-data-r2dbc/src/main/java/org/springframework/data/r2dbc/core/DefaultReactiveDataAccessStrategy.java
Lines 248 to 259 in fbe3bfb
For collections it first tries to find a common type based on the elements using
CollectionUtils.findCommonElementType((Collection<?>) value.getValue())
(which are already converted if there were elements in the array).This means that for non-empty collections it will correctly use the
Interval
type, but for empty collections it will actually useconverter.getTargetType(actualType)
, which returnsDuration
.Is there a way to get converters to work properly?
Especially since the docs say that per-element converters is the way to go:
The text was updated successfully, but these errors were encountered: