-
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
PR showing resultMap Bug when SQL using "as" aliases for column names #1100
PR showing resultMap Bug when SQL using "as" aliases for column names #1100
Conversation
Hi @dankirkd , Thank you for the test case.
And the result map is declared as follows. <resultMap type="issue1101.User" id="result2">
<id property="id" column="id"/>
<result property="name" column="name"/>
<result property="phone" column="phone_number"/>
</resultMap> There is no |
I am very surprised to hear that with 3.4.2 this test failed. We have a similar setup with the problem:
With the following resultMap definition:
The In 3.4.2 the |
It seems that in 3.4.2 and earlier |
Yes, 3.4.3+ is stricter in that sense and your code worked with 3.4.2 because of the bug fixed in #895 .
With ≤ 3.4.2 , auto-mapping is applied to the property The 3.4.2 behavior can be a problem when both columns are in the result set and
With the above example result set, the expected value of the property Hope my explanation makes sense to you. |
Also, what is my workaround? I don't think I should have to make code changes for a revision. If what you are saying is so that should have been at least a minor release change (i.e. 3.5). |
Sorry, I meant #895 (corrected the comment). I am saying that your code is invalid and it was not supposed to work in the first place. <result property="code" column="pppEEECode"/> What you need to do is to correct the mistake (i.e. rewrite the query or the result map). |
@harawata - I understand what you are saying, but I think that the previous behavior resulted in fallback behavior that could be construed as acceptable, making this not so much a bug fix, but a feature behavior change, and one that is not called out or made clear in any of the release notes or even that PR. |
OK, I'll ask other devs opinion. Please give us some time! |
Meanwhile, I am adjusting our mapper to work around the changes. But I wouldn't be surprised if others discover a similar problem. |
We just didn't realize that. I have added a note on the release note. |
Thanks. |
This PR is intended to show a bug that was introduced with mybatis 3.4.3.
I've added a couple of tests in org.apache.ibatis.submitted.automapping.AutomappingTest (shouldGetAUserWithoutAsAliases and shouldGetAUserWithAsAliases) that show the issue. The tests are the same, but the second fails using a SQL statement that include an "as" alias.
This test would have worked with mybatis 3.4.2 and earlier.
I'm not 100% sure, but I think the issue was introduced with #895.
Note: this PR is expected to fail the build because it includes tests that expose what is believed to be a bug (see #1101).