-
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
Column names with a period messes up name mapping #13
Comments
It seems to be the expected behavior. Please see the following test case: org.apache.ibatis.reflection.MetaObjectTest.shouldDemonstrateDeeplyNestedMapProperties() Do you agree to close this issue as invalid? |
I think I disagree. autoMappingBehavior is set to PARTIAL by default, which isn't supposed to auto-map nested result mappings. |
Well, it is a little bit confusing, but autoMappingBehavior=PARTIAL/FULL is applied only to nested s. public class SomeBean {
private String name;
private SomeBean child;
// accessors
} <select id="selectBean" resultType="SomeBean">
select 'A' as "name", 'B' as "child.name"
</select> Whether autoMappingBehavior is PARTIAL or FULL, this select maps 'child.name' of the resulting bean. Having said that, it might be a valid enhancement request: provide an easy way to return non-nested map when a map key contains period. |
+1 Iwao. A dot has meaning, is not just a character. This works like this by design. Not a bug in my opinion. |
It's now possible to write a custom Map wrapper that allows keys that contain period (dot) `.` or brackets `[]`. Also, it's now possible to write a custom Map wrapper by extending the built-in `MapWrapper`. Should fix mybatis#13 mybatis#2298 mybatis#3062
Edit: I've done a little more testing. It looks like any period in the column name messes it up; spaces have nothing to do with it.
I'm using version 3.2.1. I don't think the ResultHandler is necessary, but it's the scenario I had in my environment where I noticed the bug.
MyBatis output
905 [main] DEBUG IncorrectColumnNameTest.test - ooo Using Connection [com.mpti.reportlogiq.server.db.TraceConnection@16ef71]
905 [main] DEBUG IncorrectColumnNameTest.test - ==> Preparing: select 1 as [Space No Period], 2 as [Space. With Period]
906 [main] DEBUG IncorrectColumnNameTest.test - ==> Parameters:
937 [main] TRACE IncorrectColumnNameTest.test - <== Columns: Space No Period, Space. With Period
937 [main] TRACE com.mpti.reportlogiq.server.db.mappers.IncorrectColumnNameTest.test - <== Row: 1, 2
Expected output
Space No Period, Space. With Period,
1, 2,
Actual output
Space No Period, Space,
1, { With Period=2},
The text was updated successfully, but these errors were encountered: