-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Prevent foreach xml tag from polluting the global context #966
Conversation
@nyer , |
@harawata test case is added. |
Thanks for the update, @nyer ! |
Similar to #423 ? |
@Youmoo Yes, it is the same issue, but this patch does not break the existing test cases. I may need some time to review this. |
@harawata , I have updated the patch in case of null value. |
@harawata , |
You are very welcome. Thank you both for your contribution! |
…ch loop. Should fix mybatis#966 ( and mybatis#49 ).
Mybatis currently shares one global bindings context during dynamic sql building and parametemapping construction. It is ok at most time, but when it comes to the foreach xml tag, something wrong will occur. Like the following mybatis mapper:
When variable status is passed as 5, and statusList is passed as [4,5,6],it is normal when final sql will equals to
select * from tb where status = 5
. However, the final sql isselect * from tb where status =6
. The reason is that the variable status in foreach tag overwrites the outside variable with the same name. It behaves like the dynamic scope feature in programming language. It is error-prone.Please review. thank you