From: Igor K. (JIRA) <nh...@gm...> - 2011-04-08 18:09:50
|
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 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 |
From: Igor K. (JIRA) <nh...@gm...> - 2011-04-08 18:11:50
|
[ http://216.121.112.228/browse/NH-2637?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Igor Krupin updated NH-2637: ---------------------------- Attachment: Capture.PNG > 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 |
From: Igor K. (JIRA) <nh...@gm...> - 2011-04-08 18:18:03
|
[ http://216.121.112.228/browse/NH-2637?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=20865#action_20865 ] Igor Krupin commented on NH-2637: --------------------------------- Here's a link to MSDN documentation for "Type.GetProperty Method (String)" http://msdn.microsoft.com/en-us/library/kz0a8sxy.aspx "The search for name is case-sensitive. The search includes public static and public instance properties." > 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 |
From: Fabio M. (JIRA) <nh...@gm...> - 2011-04-08 18:40:01
|
[ http://216.121.112.228/browse/NH-2637?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=20866#action_20866 ] Fabio Maulo commented on NH-2637: --------------------------------- which is the bug ? I can't see it. > 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 |
From: Igor K. (JIRA) <nh...@gm...> - 2011-04-08 18:57:03
|
[ http://216.121.112.228/browse/NH-2637?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=20867#action_20867 ] Igor Krupin commented on NH-2637: --------------------------------- Oh, sorry. The bug is this. I have a database table called STUDENT. So we have something like STUDENT.FIRSTNAME STUDENT.LASTNAME In Oracle we uppercase everything (I hate Oracle, but whatever). Then, we have a class called Student, with properties FirstName and LastName (mixed case). The we do something like: ISQLQuery query = session.CreateSQLQuery("SELECT FIRSTNAME, LASTNAME FROM STUDENT"); query.SetResultTransformer(Transformers.AliasToBean(typeof(Student))); PROBLEM: AiasToBean will complain that it can't find setter property "FIRSTNAME". I traced the code to NHibernate.Properties.BasicPropertyAccessor.GetSetterOrNull method. It's looking for FIRSTNAME property, case sensitive, and can't find it. Igor > 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 |
From: Fabio M. (JIRA) <nh...@gm...> - 2011-04-10 23:13:59
|
[ http://216.121.112.228/browse/NH-2637?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Fabio Maulo closed NH-2637. --------------------------- Resolution: Not an Issue It is by design because properties and fields are case-sensitive in .NET and if you have a property called "FirstName" with a field called "firstName" the default transformer have to know to which one it have to access. You can specify the alias in your query or you can implement your AliasToEntityResultTransformer. > 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 |
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 |