We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
<if test="query.tenantId != null and query.tenantId != '' and query.tenantId != '0'"> AND tenant_id = #{query.tenantId} </if>
当tenantId ="0"时判断条件为true 会加上这个查询条件。当吧判断条件写成
<if test="query.tenantId != null and query.tenantId != '' and query.tenantId != 0"> AND tenant_id = #{query.tenantId} </if>
时判断条件为false 不会加上这个判断条件
The text was updated successfully, but these errors were encountered:
Hello @Woshizz ,
If the type of query.tenantId is String, you have to use double quotes. i.e.
query.tenantId
String
<if test='name != null and name != "" and name != "0"'>
In OGNL, a character enclosed in single quotes (e.g. '0') is recognized as a char, so query.tenantId != '0' will always be true.
'0'
char
query.tenantId != '0'
true
If this is not what you mean, please provide a test case or small demo project with assertions.
Sorry, something went wrong.
简单来说'0'是Character类型,“0”是String,0是Integer。mybatis源码中会对比较的值转换成double再比较,Stirng类型的转换是Double.parseDouble(s),Character类型的是(double)(Character)value Character被转为double会被转为ascii码
No branches or pull requests
当tenantId ="0"时判断条件为true 会加上这个查询条件。当吧判断条件写成
时判断条件为false 不会加上这个判断条件
The text was updated successfully, but these errors were encountered: