You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am encountering an issue with the <where> tag in MyBatis, specifically when it is used in a scenario where the first condition starts with an AND or OR immediately followed by a left parenthesis (. In such cases, the <where> tag does not seem to properly filter out this initial logical operator, which can lead to unexpected SQL queries and potential runtime errors.
Here is a concise example to illustrate the problem:
<selectid="testAndWithParentheses"resultMap="BaseResultMap">
select <includerefid="Base_Column_List"/>
from cm_user
<where>
AND(
1 OR NULL
)
</where>
</select>
In this example, the generated SQL query would include the leading AND, which is incorrect:
SELECT*FROM cm_user WHEREAND ( 1ORNULL )
The correct approach is to add a space after the first AND or the first OR in the <where> tag
<selectid="testAndWithParentheses"resultMap="BaseResultMap">
select <includerefid="Base_Column_List"/>
from cm_user
<where>
AND (
1 OR NULL
)
</where>
</select>
In this example, the generated SQL query would't have the leading AND, which is correct:
SELECT*FROM cm_user WHERE ( 1ORNULL )
I believe this is a bug in the MyBatis <where> tag's implementation and should be addressed to ensure that SQL queries are generated correctly and consistently.
Could you please investigate this issue and consider making a fix in a future release of MyBatis? Thank you for your attention to this matter.
Best regards
The text was updated successfully, but these errors were encountered:
Dear MyBatis Team,
I am encountering an issue with the
<where>
tag in MyBatis, specifically when it is used in a scenario where the first condition starts with anAND
orOR
immediately followed by a left parenthesis(
. In such cases, the<where>
tag does not seem to properly filter out this initial logical operator, which can lead to unexpected SQL queries and potential runtime errors.Here is a concise example to illustrate the problem:
In this example, the generated SQL query would include the leading
AND
, which is incorrect:The correct approach is to add a space after the first
AND
or the firstOR
in the<where>
tagIn this example, the generated SQL query would't have the leading
AND
, which is correct:I believe this is a bug in the MyBatis
<where>
tag's implementation and should be addressed to ensure that SQL queries are generated correctly and consistently.Could you please investigate this issue and consider making a fix in a future release of MyBatis? Thank you for your attention to this matter.
Best regards
The text was updated successfully, but these errors were encountered: