[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ic] Matrix options and set_row possible bug?


On 06/22/2006 06:57 PM, Jon Jensen wrote:
On Thu, 22 Jun 2006, Peter wrote:

Well I just figured out the problem. I'm trying to think of the best solution right now. The problem is in this block of code in set_row:

       if ($cfg->{PREFER_NULL}) {
               for (keys %{$cfg->{PREFER_NULL}}) {
                       my $i = $cfg->{COLUMN_INDEX}{$_};
                       undef $fields[$i] if $fields[$i] eq '';
               }
       }

I believe that is supposed to set any fields which are set as PREFER_NULL and have the empty string to NULL. The problem is that the if $fields[$i] eq '' returns true for undefined as well, so it causes $fields[i] to explicitly be set to undefined which causes the array to be expanded out to i-1 elements, and all of the expanded out elements are set to undefined by default which DBI translates to NULL.

I can think of a few simple solutions, moving this block down below the next if(scalar @fields == 1) { block would probably fix it and I'm inclined to do that which will probably be enough to fix the problem as long as @fields either contains only one element or a number of elements to equal the number of fields in the table. If set_row is ever called with @fields having somethign in between then there will still be problems.


Interesting. Perhaps a simple:

    undef $fields[$i] if exists $fields[$i] and $fields[$i] eq '';

would do the trick by not expanding the array.

It would, but that block is not really relevent if there's only one field passed anyways, so I figure it's just as good to simply move it down, plus it has the added benefit of not having to process unnecessary code. See the patch I just sent.

Peter
_______________________________________________
interchange-users mailing list
suppressed
http://www.icdevgroup.org/mailman/listinfo/interchange-users


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.