-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Support to assign single primitive parameter on SQL provider method #1595
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/main/java/org/apache/ibatis/builder/annotation/ProviderSqlSource.java
Outdated
Show resolved
Hide resolved
src/main/java/org/apache/ibatis/builder/annotation/ProviderSqlSource.java
Outdated
Show resolved
Hide resolved
src/main/java/org/apache/ibatis/builder/annotation/ProviderSqlSource.java
Outdated
Show resolved
Hide resolved
src/test/java/org/apache/ibatis/submitted/sqlprovider/SqlProviderTest.java
Show resolved
Hide resolved
Thanks for the PR, @masssh ! As @kazuki43zoo , if (parameterObject instanceof ParamMap) {
if (bindParameterCount == 1 && Map.class.equals(providerMethodParameterTypes[0])) {
sql = invokeProviderMethod(parameterObject); // need to add provider context?
} else {
@SuppressWarnings("unchecked")
Map<String, Object> params = (Map<String, Object>) parameterObject;
sql = invokeProviderMethod(extractProviderMethodArguments(params, providerMethodArgumentNames));
}
} else if (providerMethodParameterTypes.length == 0) {
sql = invokeProviderMethod();
} else if (providerMethodParameterTypes.length == 1) {
if (providerContext == null) {
sql = invokeProviderMethod(parameterObject);
} else {
sql = invokeProviderMethod(providerContext);
}
} else if (providerMethodParameterTypes.length == 2) {
sql = invokeProviderMethod(extractProviderMethodArguments(parameterObject));
} else {
// provider method has too many args |
Hi @harawata , Thanks for suggestion!! I will confirm your suggestion at tonight :D |
Hi, Thanks for your reviewing, @kazuki43zoo , @harawata !! |
Support to assign single primitive parameter on SQL provider method
Support to assign single primitive parameter on SQL provider method
Fix a bug in ProviderSqlSource.
A method with single primitive argument results in BuilderException.
Example (kotlin):
If
AuthorDao#fetchOneById()
would be called likeauthorDao.fetchOneById(10)
, following exception will occur.