Thread: Perl DBIx::SearchBuilder and pg_atoi: zero-length string?

Perl DBIx::SearchBuilder and pg_atoi: zero-length string?

From
Steve Wampler
Date:
Hi,

I just discovered that perl module: DBIx::SearchBuilder 0.97
has a LoadByCols() method that builds a generic SELECT
query that seems to assume '' is a valid value to test on
any field.  (The code is :
------------------------------------------------------------------
sub LoadByCols  {
    my $self = shift;
    my %hash  = (@_);
    my (@bind, @phrases);
    foreach my $key (keys %hash) {
        if (defined $hash{$key} &&  $hash{$key} ne '') {
        my $op;
        my $value;
        if (ref $hash{$key} eq 'HASH') {
            $op = $hash{$key}->{operator};
            $value = $hash{$key}->{value};
       } else {
            $op = '=';
            $value = $hash{$key};
        }

                push @phrases, "$key $op ?";
                push @bind, $value;
        }
        else {
                push @phrases, "($key IS NULL OR $key = '')";
        }
    }

    my $QueryString = "SELECT  * FROM ".$self->Table." WHERE ".
    join(' AND ', @phrases) ;
    return ($self->_LoadFromSQL($QueryString, @bind));
}
-----------------------------------------------------------
)

PG 7.3.4 generates a "pg_atoi: zero-length string" error
when '' can't be coerced to the column type.  I understand
the reason for changing this behavior from 7.2...

Can anyone point me to a version of DBIx::SearchBuilder that
works with PG 7.3.4 and above?

Thanks!
Steve
--
Steve Wampler -- swampler@noao.edu
The gods that smiled on your birth are now laughing out loud.

Re: Perl DBIx::SearchBuilder and pg_atoi: zero-length string?

From
Vivek Khera
Date:
>>>>> "SW" == Steve Wampler <swampler@noao.edu> writes:

SW> Hi,
SW> I just discovered that perl module: DBIx::SearchBuilder 0.97
SW> has a LoadByCols() method that builds a generic SELECT
SW> query that seems to assume '' is a valid value to test on
SW> any field.  (The code is :

All such bugs should be out of SearchBuilder.  I'd file a but report
either via CPAN (www.cpan.org) or with the author directly.  He's
pretty good getting these things fixed.


--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Vivek Khera, Ph.D.                Khera Communications, Inc.
Internet: khera@kciLink.com       Rockville, MD  +1-301-869-4449 x806
AIM: vivekkhera Y!: vivek_khera   http://www.khera.org/~vivek/