You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Martin Ellis <ma...@ellis.name> on 2009/10/02 20:56:26 UTC

Case sensitivity in DefaultResultSetHandler

Hi,

I'm running into a problem using trunk, specifically with version:
r819833 | cbegin | 2009-09-29 06:43:58 +0100 (Tue, 29 Sep 2009) | 2 lines
Support single column mappings in primitive results


I have a SELECT statement that uses AS to name a few columns.
I have a resultMap that refers the AS names (not the DB column
names), which in turn maps to property names on a bean.

This all works hunky-dorey in 3.0.* releases, up to 3.0-beta-3.
But, in the releases, loading associations seems to be broken
in a way that I can't understand, which is why I'm trying trunk... :o)

In trunk, the association loading works as I'd expect, but
*something's* going wrong with all those renamings.  There
seems to be a case sensitivity issue in
DefaultResultSetHandler#getRowValue().

It calls loadMappedAndUnmappedColumnNames, which
populates two lists with (uncapitalised) column names.
This is then passed to applyPropertyMappings, which
searches the same lists for upper-cased column names:

   if (propertyMapping.isCompositeResult()
     || (column != null && mappedColumnNames.contains(column.toUpperCase()))) {


I've got stuff working as I'd like with the following change:

--- a/ibatis-3-core/src/main/java/org/apache/ibatis/executor/resultset/DefaultResultSetHandler.java
+++ b/ibatis-3-core/src/main/java/org/apache/ibatis/executor/resultset/DefaultResultSetHandler.java
@@ -265,9 +265,9 @@ public class DefaultResultSetHandler implements
ResultSetHandler {
       final String columnName = configuration.isUseColumnLabel() ?
rsmd.getColumnLabel(i) : rsmd.getColumnName(i);
       final String upperColumnName = columnName.toUpperCase();
       if (mappedColumns.contains(upperColumnName)) {
-        mappedColumnNames.add(columnName);
+        mappedColumnNames.add(upperColumnName);
       } else {
-        unmappedColumnNames.add(columnName);
+        unmappedColumnNames.add(upperColumnName);
       }
     }
   }

I wonder if perhaps someone more familiar with the code could
check the logic there?  I've been using iBATIS for all of about
a week, so unfortunately I'm not that familiar with its workings.


Best Regards,

Martin

---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Re: Case sensitivity in DefaultResultSetHandler

Posted by Clinton Begin <cl...@gmail.com>.
You should log a JIRA ticket.  Our general rule of thumb is:  If it isn't in
Jira, it's not getting done.

The one I addressed was in SqlRunner and was a Jira ticket logged against
the migrations framework.

Clinton

On Sun, Oct 4, 2009 at 2:41 PM, Martin Ellis <el...@gmail.com> wrote:

> On Fri, Oct 2, 2009 at 9:40 PM, Clinton Begin <cl...@gmail.com>
> wrote:
> > Unfortunately, by coincidence, I'm currently rewriting the entire
> > DefaultResultSetHandler -- in a serious way.  It's currently in a real
> state
> > of flux.
> > I'll work on it this weekend some more to try to get it to a Beta 4.
>  Your
> > feedback will come in handy for sure.
>
> I can see a number of commits from this weekend - seems you have been busy!
>
> However, from reviewing the changes, it looks as though I'll still
> have the problems I described: loadMappedAndUnmappedColumnNames adding
> mixed case column names to a list, and applyPropertyMappings searching
> for the upper-cased name.
>
> The only case sensitivity issues I saw addressed affected SqlRunner.
> I'll check tomorrow to be sure, though.
>
> Cheers
> Martin
>
>
> > On Fri, Oct 2, 2009 at 12:56 PM, Martin Ellis <ma...@ellis.name>
> >> There
> >> seems to be a case sensitivity issue in
> >> DefaultResultSetHandler#getRowValue().
> >>
> >> It calls loadMappedAndUnmappedColumnNames, which
> >> populates two lists with (uncapitalised) column names.
> >> This is then passed to applyPropertyMappings, which
> >> searches the same lists for upper-cased column names:
> >>
> >>   if (propertyMapping.isCompositeResult()
> >>     || (column != null &&
> >> mappedColumnNames.contains(column.toUpperCase()))) {
> >>
> >>
> >> I've got stuff working as I'd like with the following change:
> >>
> >> ---
> >>
> a/ibatis-3-core/src/main/java/org/apache/ibatis/executor/resultset/DefaultResultSetHandler.java
> >> +++
> >>
> b/ibatis-3-core/src/main/java/org/apache/ibatis/executor/resultset/DefaultResultSetHandler.java
> >> @@ -265,9 +265,9 @@ public class DefaultResultSetHandler implements
> >> ResultSetHandler {
> >>       final String columnName = configuration.isUseColumnLabel() ?
> >> rsmd.getColumnLabel(i) : rsmd.getColumnName(i);
> >>       final String upperColumnName = columnName.toUpperCase();
> >>       if (mappedColumns.contains(upperColumnName)) {
> >> -        mappedColumnNames.add(columnName);
> >> +        mappedColumnNames.add(upperColumnName);
> >>       } else {
> >> -        unmappedColumnNames.add(columnName);
> >> +        unmappedColumnNames.add(upperColumnName);
> >>       }
> >>     }
> >>   }
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
>

Re: Case sensitivity in DefaultResultSetHandler

Posted by Martin Ellis <el...@gmail.com>.
You'll have seen the JIRA emails, but for the list archives, link is:

http://issues.apache.org/jira/browse/IBATIS-668

Cheers
Martin


On Sun, Oct 4, 2009 at 10:38 PM, Clinton Begin <cl...@gmail.com> wrote:
> And if you have a patch, you can attach it to the Jira ticket.
>
> On Sun, Oct 4, 2009 at 2:41 PM, Martin Ellis <el...@gmail.com> wrote:
>>
>> On Fri, Oct 2, 2009 at 9:40 PM, Clinton Begin <cl...@gmail.com>
>> wrote:
>> > Unfortunately, by coincidence, I'm currently rewriting the entire
>> > DefaultResultSetHandler -- in a serious way.  It's currently in a real
>> > state
>> > of flux.
>> > I'll work on it this weekend some more to try to get it to a Beta 4.
>> >  Your
>> > feedback will come in handy for sure.
>>
>> I can see a number of commits from this weekend - seems you have been
>> busy!
>>
>> However, from reviewing the changes, it looks as though I'll still
>> have the problems I described: loadMappedAndUnmappedColumnNames adding
>> mixed case column names to a list, and applyPropertyMappings searching
>> for the upper-cased name.
>>
>> The only case sensitivity issues I saw addressed affected SqlRunner.
>> I'll check tomorrow to be sure, though.
>>
>> Cheers
>> Martin
>>
>>
>> > On Fri, Oct 2, 2009 at 12:56 PM, Martin Ellis <ma...@ellis.name>
>> >> There
>> >> seems to be a case sensitivity issue in
>> >> DefaultResultSetHandler#getRowValue().
>> >>
>> >> It calls loadMappedAndUnmappedColumnNames, which
>> >> populates two lists with (uncapitalised) column names.
>> >> This is then passed to applyPropertyMappings, which
>> >> searches the same lists for upper-cased column names:
>> >>
>> >>   if (propertyMapping.isCompositeResult()
>> >>     || (column != null &&
>> >> mappedColumnNames.contains(column.toUpperCase()))) {
>> >>
>> >>
>> >> I've got stuff working as I'd like with the following change:
>> >>
>> >> ---
>> >>
>> >> a/ibatis-3-core/src/main/java/org/apache/ibatis/executor/resultset/DefaultResultSetHandler.java
>> >> +++
>> >>
>> >> b/ibatis-3-core/src/main/java/org/apache/ibatis/executor/resultset/DefaultResultSetHandler.java
>> >> @@ -265,9 +265,9 @@ public class DefaultResultSetHandler implements
>> >> ResultSetHandler {
>> >>       final String columnName = configuration.isUseColumnLabel() ?
>> >> rsmd.getColumnLabel(i) : rsmd.getColumnName(i);
>> >>       final String upperColumnName = columnName.toUpperCase();
>> >>       if (mappedColumns.contains(upperColumnName)) {
>> >> -        mappedColumnNames.add(columnName);
>> >> +        mappedColumnNames.add(upperColumnName);
>> >>       } else {
>> >> -        unmappedColumnNames.add(columnName);
>> >> +        unmappedColumnNames.add(upperColumnName);
>> >>       }
>> >>     }
>> >>   }
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
>> For additional commands, e-mail: user-java-help@ibatis.apache.org
>>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Re: Case sensitivity in DefaultResultSetHandler

Posted by Clinton Begin <cl...@gmail.com>.
And if you have a patch, you can attach it to the Jira ticket.

On Sun, Oct 4, 2009 at 2:41 PM, Martin Ellis <el...@gmail.com> wrote:

> On Fri, Oct 2, 2009 at 9:40 PM, Clinton Begin <cl...@gmail.com>
> wrote:
> > Unfortunately, by coincidence, I'm currently rewriting the entire
> > DefaultResultSetHandler -- in a serious way.  It's currently in a real
> state
> > of flux.
> > I'll work on it this weekend some more to try to get it to a Beta 4.
>  Your
> > feedback will come in handy for sure.
>
> I can see a number of commits from this weekend - seems you have been busy!
>
> However, from reviewing the changes, it looks as though I'll still
> have the problems I described: loadMappedAndUnmappedColumnNames adding
> mixed case column names to a list, and applyPropertyMappings searching
> for the upper-cased name.
>
> The only case sensitivity issues I saw addressed affected SqlRunner.
> I'll check tomorrow to be sure, though.
>
> Cheers
> Martin
>
>
> > On Fri, Oct 2, 2009 at 12:56 PM, Martin Ellis <ma...@ellis.name>
> >> There
> >> seems to be a case sensitivity issue in
> >> DefaultResultSetHandler#getRowValue().
> >>
> >> It calls loadMappedAndUnmappedColumnNames, which
> >> populates two lists with (uncapitalised) column names.
> >> This is then passed to applyPropertyMappings, which
> >> searches the same lists for upper-cased column names:
> >>
> >>   if (propertyMapping.isCompositeResult()
> >>     || (column != null &&
> >> mappedColumnNames.contains(column.toUpperCase()))) {
> >>
> >>
> >> I've got stuff working as I'd like with the following change:
> >>
> >> ---
> >>
> a/ibatis-3-core/src/main/java/org/apache/ibatis/executor/resultset/DefaultResultSetHandler.java
> >> +++
> >>
> b/ibatis-3-core/src/main/java/org/apache/ibatis/executor/resultset/DefaultResultSetHandler.java
> >> @@ -265,9 +265,9 @@ public class DefaultResultSetHandler implements
> >> ResultSetHandler {
> >>       final String columnName = configuration.isUseColumnLabel() ?
> >> rsmd.getColumnLabel(i) : rsmd.getColumnName(i);
> >>       final String upperColumnName = columnName.toUpperCase();
> >>       if (mappedColumns.contains(upperColumnName)) {
> >> -        mappedColumnNames.add(columnName);
> >> +        mappedColumnNames.add(upperColumnName);
> >>       } else {
> >> -        unmappedColumnNames.add(columnName);
> >> +        unmappedColumnNames.add(upperColumnName);
> >>       }
> >>     }
> >>   }
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
>

Re: Case sensitivity in DefaultResultSetHandler

Posted by Martin Ellis <el...@gmail.com>.
On Fri, Oct 2, 2009 at 9:40 PM, Clinton Begin <cl...@gmail.com> wrote:
> Unfortunately, by coincidence, I'm currently rewriting the entire
> DefaultResultSetHandler -- in a serious way.  It's currently in a real state
> of flux.
> I'll work on it this weekend some more to try to get it to a Beta 4.  Your
> feedback will come in handy for sure.

I can see a number of commits from this weekend - seems you have been busy!

However, from reviewing the changes, it looks as though I'll still
have the problems I described: loadMappedAndUnmappedColumnNames adding
mixed case column names to a list, and applyPropertyMappings searching
for the upper-cased name.

The only case sensitivity issues I saw addressed affected SqlRunner.
I'll check tomorrow to be sure, though.

Cheers
Martin


> On Fri, Oct 2, 2009 at 12:56 PM, Martin Ellis <ma...@ellis.name>
>> There
>> seems to be a case sensitivity issue in
>> DefaultResultSetHandler#getRowValue().
>>
>> It calls loadMappedAndUnmappedColumnNames, which
>> populates two lists with (uncapitalised) column names.
>> This is then passed to applyPropertyMappings, which
>> searches the same lists for upper-cased column names:
>>
>>   if (propertyMapping.isCompositeResult()
>>     || (column != null &&
>> mappedColumnNames.contains(column.toUpperCase()))) {
>>
>>
>> I've got stuff working as I'd like with the following change:
>>
>> ---
>> a/ibatis-3-core/src/main/java/org/apache/ibatis/executor/resultset/DefaultResultSetHandler.java
>> +++
>> b/ibatis-3-core/src/main/java/org/apache/ibatis/executor/resultset/DefaultResultSetHandler.java
>> @@ -265,9 +265,9 @@ public class DefaultResultSetHandler implements
>> ResultSetHandler {
>>       final String columnName = configuration.isUseColumnLabel() ?
>> rsmd.getColumnLabel(i) : rsmd.getColumnName(i);
>>       final String upperColumnName = columnName.toUpperCase();
>>       if (mappedColumns.contains(upperColumnName)) {
>> -        mappedColumnNames.add(columnName);
>> +        mappedColumnNames.add(upperColumnName);
>>       } else {
>> -        unmappedColumnNames.add(columnName);
>> +        unmappedColumnNames.add(upperColumnName);
>>       }
>>     }
>>   }

---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Re: Case sensitivity in DefaultResultSetHandler

Posted by Clinton Begin <cl...@gmail.com>.
Wow, someone is using trunk!  Crazy, but awesome.
Unfortunately, by coincidence, I'm currently rewriting the entire
DefaultResultSetHandler -- in a serious way.  It's currently in a real state
of flux.

I'll work on it this weekend some more to try to get it to a Beta 4.  Your
feedback will come in handy for sure.

Clinton

On Fri, Oct 2, 2009 at 12:56 PM, Martin Ellis <ma...@ellis.name> wrote:

> Hi,
>
> I'm running into a problem using trunk, specifically with version:
> r819833 | cbegin | 2009-09-29 06:43:58 +0100 (Tue, 29 Sep 2009) | 2 lines
> Support single column mappings in primitive results
>
>
> I have a SELECT statement that uses AS to name a few columns.
> I have a resultMap that refers the AS names (not the DB column
> names), which in turn maps to property names on a bean.
>
> This all works hunky-dorey in 3.0.* releases, up to 3.0-beta-3.
> But, in the releases, loading associations seems to be broken
> in a way that I can't understand, which is why I'm trying trunk... :o)
>
> In trunk, the association loading works as I'd expect, but
> *something's* going wrong with all those renamings.  There
> seems to be a case sensitivity issue in
> DefaultResultSetHandler#getRowValue().
>
> It calls loadMappedAndUnmappedColumnNames, which
> populates two lists with (uncapitalised) column names.
> This is then passed to applyPropertyMappings, which
> searches the same lists for upper-cased column names:
>
>   if (propertyMapping.isCompositeResult()
>     || (column != null &&
> mappedColumnNames.contains(column.toUpperCase()))) {
>
>
> I've got stuff working as I'd like with the following change:
>
> ---
> a/ibatis-3-core/src/main/java/org/apache/ibatis/executor/resultset/DefaultResultSetHandler.java
> +++
> b/ibatis-3-core/src/main/java/org/apache/ibatis/executor/resultset/DefaultResultSetHandler.java
> @@ -265,9 +265,9 @@ public class DefaultResultSetHandler implements
> ResultSetHandler {
>       final String columnName = configuration.isUseColumnLabel() ?
> rsmd.getColumnLabel(i) : rsmd.getColumnName(i);
>       final String upperColumnName = columnName.toUpperCase();
>       if (mappedColumns.contains(upperColumnName)) {
> -        mappedColumnNames.add(columnName);
> +        mappedColumnNames.add(upperColumnName);
>       } else {
> -        unmappedColumnNames.add(columnName);
> +        unmappedColumnNames.add(upperColumnName);
>       }
>     }
>   }
>
> I wonder if perhaps someone more familiar with the code could
> check the logic there?  I've been using iBATIS for all of about
> a week, so unfortunately I'm not that familiar with its workings.
>
>
> Best Regards,
>
> Martin
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
>