Skip to content

Conversation

@abel533
Copy link
Contributor

@abel533 abel533 commented Aug 23, 2021

trim, set, where label add notEmpty attr.

When notempty is set, an exception is thrown if the content of the element is empty. The settings here can avoid dangerous SQL.

Example:

<select id="getUserIfNode" resultType="org.apache.ibatis.submitted.ognlstatic.User">
   select * from users
  <where notEmpty="query criteria cannot be blank">
   <if test="value not in {null, ''}">
   name = #{value}
   </if>
   </where>
</select>

<delete id="deleteAuthor" parameterType="int">
    delete from Author
    <where notEmpty="Dangerous: clear the table!">
    <if test="id!=null">
    id = #{id}
    </if>
    </where>
</delete>

If it is useful, I will add some tests.

…ception is thrown if the content of the element is empty. The settings here can avoid dangerous SQL.
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.02%) to 87.237% when pulling a176431 on abel533:notEmpty into e257a1d on mybatis:master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants