You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ibatis.apache.org by "Henrik Uffe Jensen (JIRA)" <ib...@incubator.apache.org> on 2004/12/17 19:46:12 UTC

[jira] Created: (IBATISNET-13) nullValue not working with GUIDs

nullValue not working with GUIDs
--------------------------------

         Key: IBATISNET-13
         URL: http://nagoya.apache.org/jira/browse/IBATISNET-13
     Project: iBatis for .NET
        Type: Bug
    Reporter: Henrik Uffe Jensen



Convert.ChangeType for some reason does not support GUIDs, so when the 'nullValue' attribute is used on a parameter in a parameterMap an exception is thrown. 

In IBatisNet.DataMapper.Configuration.ParameterMapping.ParameterMap.GetValueOfProperty() the nullValue to use for comparing is retrieved with the following code, where the Convert.ChangeType does not like a Guid

if (propertyInfo.PropertyType == typeof(System.Decimal))
{
    CultureInfo culture = new CultureInfo( "en-US" );
    // nullValue decimal must be  ######.##
    nullValue = decimal.Parse( property.NullValue, culture);
}
else
{
    nullValue = Convert.ChangeType( property.NullValue, propertyInfo.PropertyType );
}

The solution is to handle GUIDs as a special case just as is already done with Decimal values. I tested with the following code and nullValue="00000000-0000-0000-0000-000000000000" and then using Guid.Empty on my properties and it worked fine

if (propertyInfo.PropertyType == typeof(System.Decimal))
{
         CultureInfo culture = new CultureInfo( "en-US" );
	 // nullValue decimal must be  ######.##
	nullValue = decimal.Parse( property.NullValue, culture);
}
else if (propertyInfo.PropertyType == typeof(System.Guid))
{
        nullValue = new Guid(property.NullValue);
}
else
{
	nullValue = Convert.ChangeType( property.NullValue, propertyInfo.PropertyType );
}





-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://nagoya.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


[jira] Assigned: (IBATISNET-13) nullValue not working with GUIDs

Posted by "Gilles Bayon (JIRA)" <ib...@incubator.apache.org>.
     [ http://nagoya.apache.org/jira/browse/IBATISNET-13?page=history ]

Gilles Bayon reassigned IBATISNET-13:
-------------------------------------

    Assign To: Gilles Bayon

> nullValue not working with GUIDs
> --------------------------------
>
>          Key: IBATISNET-13
>          URL: http://nagoya.apache.org/jira/browse/IBATISNET-13
>      Project: iBatis for .NET
>         Type: Bug
>     Reporter: Henrik Uffe Jensen
>     Assignee: Gilles Bayon

>
> Convert.ChangeType for some reason does not support GUIDs, so when the 'nullValue' attribute is used on a parameter in a parameterMap an exception is thrown. 
> In IBatisNet.DataMapper.Configuration.ParameterMapping.ParameterMap.GetValueOfProperty() the nullValue to use for comparing is retrieved with the following code, where the Convert.ChangeType does not like a Guid
> if (propertyInfo.PropertyType == typeof(System.Decimal))
> {
>     CultureInfo culture = new CultureInfo( "en-US" );
>     // nullValue decimal must be  ######.##
>     nullValue = decimal.Parse( property.NullValue, culture);
> }
> else
> {
>     nullValue = Convert.ChangeType( property.NullValue, propertyInfo.PropertyType );
> }
> The solution is to handle GUIDs as a special case just as is already done with Decimal values. I tested with the following code and nullValue="00000000-0000-0000-0000-000000000000" and then using Guid.Empty on my properties and it worked fine
> if (propertyInfo.PropertyType == typeof(System.Decimal))
> {
>          CultureInfo culture = new CultureInfo( "en-US" );
> 	 // nullValue decimal must be  ######.##
> 	nullValue = decimal.Parse( property.NullValue, culture);
> }
> else if (propertyInfo.PropertyType == typeof(System.Guid))
> {
>         nullValue = new Guid(property.NullValue);
> }
> else
> {
> 	nullValue = Convert.ChangeType( property.NullValue, propertyInfo.PropertyType );
> }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://nagoya.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


[jira] Closed: (IBATISNET-13) nullValue not working with GUIDs

Posted by "Gilles Bayon (JIRA)" <ib...@incubator.apache.org>.
     [ http://nagoya.apache.org/jira/browse/IBATISNET-13?page=history ]
     
Gilles Bayon closed IBATISNET-13:
---------------------------------

    Resolution: Fixed

It will be in the next release 1.1 (it's already in SVN if you want to try it). 

> nullValue not working with GUIDs
> --------------------------------
>
>          Key: IBATISNET-13
>          URL: http://nagoya.apache.org/jira/browse/IBATISNET-13
>      Project: iBatis for .NET
>         Type: Bug
>     Reporter: Henrik Uffe Jensen
>     Assignee: Gilles Bayon

>
> Convert.ChangeType for some reason does not support GUIDs, so when the 'nullValue' attribute is used on a parameter in a parameterMap an exception is thrown. 
> In IBatisNet.DataMapper.Configuration.ParameterMapping.ParameterMap.GetValueOfProperty() the nullValue to use for comparing is retrieved with the following code, where the Convert.ChangeType does not like a Guid
> if (propertyInfo.PropertyType == typeof(System.Decimal))
> {
>     CultureInfo culture = new CultureInfo( "en-US" );
>     // nullValue decimal must be  ######.##
>     nullValue = decimal.Parse( property.NullValue, culture);
> }
> else
> {
>     nullValue = Convert.ChangeType( property.NullValue, propertyInfo.PropertyType );
> }
> The solution is to handle GUIDs as a special case just as is already done with Decimal values. I tested with the following code and nullValue="00000000-0000-0000-0000-000000000000" and then using Guid.Empty on my properties and it worked fine
> if (propertyInfo.PropertyType == typeof(System.Decimal))
> {
>          CultureInfo culture = new CultureInfo( "en-US" );
> 	 // nullValue decimal must be  ######.##
> 	nullValue = decimal.Parse( property.NullValue, culture);
> }
> else if (propertyInfo.PropertyType == typeof(System.Guid))
> {
>         nullValue = new Guid(property.NullValue);
> }
> else
> {
> 	nullValue = Convert.ChangeType( property.NullValue, propertyInfo.PropertyType );
> }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://nagoya.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira