-
Notifications
You must be signed in to change notification settings - Fork 132
#421 - Handle modifying query methods returning kotlin.Unit. #422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#421 - Handle modifying query methods returning kotlin.Unit. #422
Conversation
….Unit. Added check for kotlin.Unit to AbstractR2dbcQuery#getExecutionToWrap. This case is essentially equivalent to a return type of Void, but the singleton Unit instance needs to be returned instead of discarding the result entirely. It was also necessary to add a check to R2dbcQueryMethod#getEntityInformation, as otherwise a PersistentEntity is created for Unit, which leads to a new instance being created via reflection down the pipeline (which is probably not a thing that should happen). Added AbstractR2dbcQueryUnitTests to test the functionality surrounding the main change. Also added integration tests surrounding modifying query return types.
Thanks for submitting a pull request. We had a look and indeed checking for I'm going to merge test and documentation changes from this pull request. |
…Unit. We now discard results for suspended query methods if the return type is kotlin.Unit. Related ticket: DATACMNS-1779 Original pull request: #422.
Added check for kotlin.Unit to AbstractR2dbcQuery#getExecutionToWrap. This case is essentially equivalent to a return type of Void, but the singleton Unit instance needs to be returned instead of discarding the result entirely. It was also necessary to add a check to R2dbcQueryMethod#getEntityInformation, as otherwise a PersistentEntity is created for Unit, which leads to a new instance being created via reflection down the pipeline (which is probably not a thing that should happen). Original pull request: #422.
Simplify tests. Use ReflectionUtils.isVoid(…) where possible and simplify isVoid(…) flows. Original pull request: #422.
…Unit. We now discard results for suspended query methods if the return type is kotlin.Unit. Related ticket: DATACMNS-1779 Original pull request: #422.
Added check for kotlin.Unit to AbstractR2dbcQuery#getExecutionToWrap. This case is essentially equivalent to a return type of Void, but the singleton Unit instance needs to be returned instead of discarding the result entirely. It was also necessary to add a check to R2dbcQueryMethod#getEntityInformation, as otherwise a PersistentEntity is created for Unit, which leads to a new instance being created via reflection down the pipeline (which is probably not a thing that should happen). Original pull request: #422.
Simplify tests. Use ReflectionUtils.isVoid(…) where possible and simplify isVoid(…) flows. Original pull request: #422.
Thank you for your contribution. That's merged, polished, and backported now. |
Added check for
kotlin.Unit
toAbstractR2dbcQuery#getExecutionToWrap
. This case is essentially equivalent to a return type ofVoid
, but the singletonUnit
instance needs to be returned instead of discarding the result entirely.It was also necessary to add a check to
R2dbcQueryMethod#getEntityInformation
, as otherwise aPersistentEntity
is created forUnit
, which leads to a new instance being created via reflection down the pipeline (which is probably not a thing that should happen).Added
AbstractR2dbcQueryUnitTests
to test the functionality surrounding the main change. Also added integration tests surrounding modifying query return types.A couple notes:
R2dbcQueryMethod#getEntityInformation
is sufficient to prevent aPersistentEntity
or new instance ofUnit
from being created for this particular case, I feel like it might be a good idea to add an additional check forUnit
toSimpleTypeHolder
, alongside the one forjava.lang.*
. I'm not sure whether there's a need for a broaderkotlin.*
check, though.KotlinDetector.isKotlinPresent() && Unit.class.isAssignableFrom(someClass)
all over the place. I don't think a check forUnit
belongs inClassUtils.isPrimitiveOrWrapper
as, strictly speaking,Unit
is neither of those, but perhaps anisKotlinUnit(Class)
method could be added toKotlinDetector
.(I decided to submit this PR without either of those improvements since those are both in other repos and the solution works as-is for now. I'd like to know your thoughts on this PR and those/any other potential improvements before I go submitting any additional PRs elsewhere.)