Closed oktupol closed 7 months ago
Good catch. I'd argue that the converter lookup must check for resultType
instead of entityType
. Have you tried switching the target type and running your tests?
It would be also great to have a test along with your changes.
You're right, Switching these two variables also solves this issue.
I added a test case, but I'm not sure whether my testing approach is ideal.
Thanks a lot. The changes look decent and the fix is much more efficient.
Thank you for your contribution. That's merged, polished, and backported now.
This change fixes a bug introduced with version 3.2.2 of spring-data-r2dbc.
Scenario:
An entity
ExampleEntity
exists, along with a ReactiveCrudRepositoryExampleRepository
.ExampleEntity
has following fields:ExampleRepository
has following method: {Additionally, an explicit converter exists for ExampleEntity:
Up until Version 3.2.1, invoking
ExampleRepository.countBySomeFieldEqualsTest
worked. Upon invocation, at some point, the method changed in this Pull RequestgetRowsFetchSpec
checks which, if any, converter shall be used for converting the row fetched from the database.The implementation up until 3.2.1 was:
however, the new implementation breaks things:
Becuase of this, the result of the "SELECT COUNT(*)..." query above is fed into RowToExampleEntityConverter.convert, which expects a different input format.
By switching around these two if-blocks, the implementation works again in the shown scenario, which is why I would like to propose this change.