From: Igor K. (JIRA) <nh...@gm...> - 2011-04-11 15:59:11
|
[ http://216.121.112.228/browse/NH-2637?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=20886#action_20886 ] Igor Krupin commented on NH-2637: --------------------------------- No no no! I downloaded source code to NHibernate 2.1 (the one we are using), and here's what I see: The method is GetSetterOrNull in BasicPropertyAccessor: // the BindingFlags.IgnoreCase is important here because if type is a struct, the GetProperty method does // not ignore case by default. If type is a class, it _does_ ignore case... we're better off explicitly // stating that casing should be ignored so we get the same behavior for both structs and classes PropertyInfo property = type.GetProperty(propertyName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly | BindingFlags.IgnoreCase); ================================== Once again, the comment is incorrect, but the code used to work! Why? Because even though the assumption that by default GetProperty is case insensitive is incorrect the flag IgnoreCase has been added anyway. ================================== This is a breaking change! We cannot upgrade to 3.1 because of this. I read all the change logs and nowhere does it mention that a "new feature" or whatever has been introduced whereby the properties-to-columns are now case sensitive!!! ================================== "You can specify the alias in your query or you can implement your AliasToEntityResultTransformer." - We have production tables with hundreds of columns, and we have tens of production projects using those tables. We cannot go and change our queries now all over the place, only b/c we want 3.1 to work. > NHibernate.Properties.BasicPropertyAccessor.GetSetterOrNull is case sensitive > ----------------------------------------------------------------------------- > > Key: NH-2637 > URL: http://216.121.112.228/browse/NH-2637 > Project: NHibernate > Issue Type: Bug > Components: Core > Affects Versions: 3.1.0 > Reporter: Igor Krupin > Priority: Major > Attachments: Capture.PNG > > > We are running NH 2.1 and discovered this bug trying to upgrade to NH 3.1. We do a lot of AliasToBean stuff, mapping tables to DTOs, and AliasToBean will call this method to get the properties. Problem is, it's case sensitive now! Reading code comments i see this: > ============ <CODE SNIPPET> ================ > BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly; > if (type.IsValueType) > { > // the BindingFlags.IgnoreCase is important here because if type is a struct, the GetProperty method does > // not ignore case by default. If type is a class, it _does_ ignore case... we're better off explicitly > // stating that casing should be ignored so we get the same behavior for both structs and classes > bindingFlags = bindingFlags | BindingFlags.IgnoreCase; > } > ============ </CODE SNIPPET> ================ > "If type is a class, it _does_ ignore case..." -- incorrect. By default in classes case will _not_ be ignored, you explicitly have to specify it using a flag, same as you do for value type. > The fix for this is rather simple, just add the BindingFlags.IgnoreCase flag and all's good. No need for the "if (type.IsValueType)" anymore either. GetGetterOrNull suffers from the same. > Thank You!!! > Igor -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://216.121.112.228/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |