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
only one parameter not use @param, may not work for DynamicSqlSource #1950
Comments
Could you try latest version (3.5.5)? Probably, this issue has been fixed since 3.5.2 via gh-1487. |
If you cannot upgrade to 3.5.2+, you need to use the Thanks. |
thank you very much for so rapid response; |
In latest version, there are many enhancements from 3.4.x. |
MyBatis version
3.4.6
Database vendor and version
5.7.20
i has a question in mybatis:3.4.6;
#the sql refer method
List selectOnlyIf(String entryDate);
when our sql has only one parameter, it't not must to add @param annotation;
as follow, this run ok,
is's because when runing,in MapperMethod.convertArgsToSqlCommandParam inner,
it jude, when don't have @param and paramCount=1, it's return origin parameterObject;
but,when my SQL change as follow:
SELECT * from tb_userInfo where <if test="entryDate!=null"> entry_date = #{entryDate} </if> order by id desc
this sql will change to dynamic;
when DynamicSqlSource => rootSqlNode.apply(context);
rootSqlNode while contain four SqlNode: StaticTextSqlNode,StaticTextSqlNode,IfSqlNode,StaticTextSqlNode
when IfSqlNode apply:
evaluator.evaluateBoolean(test, context.getBindings()))
here it real like: evaluator.evaluateBoolean("entryDate!=null", context.getBindings()))
DynamicContext has two key:
_parameter: ?
_databaseId: null
MetaObject parameterMetaObject,here,it's string;
OGNL.getValue, can't find any key for entryDate,will thrown error;
So, only one parameter not use @param can use for RawSqlSource,
but not apply for DynamicSqlSource,
this design, is a problem or we use it in the wrong way ?
The text was updated successfully, but these errors were encountered: