my $hashref = $self->{'Hash'} = shift;
- foreach my $field ( $self->fields ) {
- $hashref->{$field}='' unless defined $hashref->{$field};
- #trim the '$' and ',' from money fields for Pg (belong HERE?)
- #(what about Pg i18n?)
- if ( driver_name =~ /^Pg$/i
- && $self->dbdef_table->column($field)->type eq 'money' ) {
- ${$hashref}{$field} =~ s/^\$//;
- ${$hashref}{$field} =~ s/\,//;
- }
+ foreach my $field ( grep !defined($hashref->{$_}), $self->fields ) {
+ $hashref->{$field}='';
}
$self->_cache($hashref, shift) if $self->can('_cache') && @_;
$statement .= ' WHERE '. join(' AND ', map {
my $op = '=';
+ my $column = $_;
if ( ref($record->{$_}) ) {
$op = $record->{$_}{'op'} if $record->{$_}{'op'};
- $op = 'LIKE' if $op =~ /^ILIKE$/i && driver_name !~ /^Pg$/i;
+ #$op = 'LIKE' if $op =~ /^ILIKE$/i && driver_name !~ /^Pg$/i;
+ if ( uc($op) eq 'ILIKE' ) {
+ $op = 'LIKE';
+ $record->{$_}{'value'} = lc($record->{$_}{'value'});
+ $column = "LOWER($_)";
+ }
$record->{$_} = $record->{$_}{'value'}
}
if ( ! defined( $record->{$_} ) || $record->{$_} eq '' ) {
if ( $op eq '=' ) {
if ( driver_name =~ /^Pg$/i ) {
- qq-( $_ IS NULL OR $_ = '' )-;
+ qq-( $column IS NULL OR $column = '' )-;
} else {
- qq-( $_ IS NULL OR $_ = "" )-;
+ qq-( $column IS NULL OR $column = "" )-;
}
} elsif ( $op eq '!=' ) {
if ( driver_name =~ /^Pg$/i ) {
- qq-( $_ IS NOT NULL AND $_ != '' )-;
+ qq-( $column IS NOT NULL AND $column != '' )-;
} else {
- qq-( $_ IS NOT NULL AND $_ != "" )-;
+ qq-( $column IS NOT NULL AND $column != "" )-;
}
} else {
if ( driver_name =~ /^Pg$/i ) {
- qq-( $_ $op '' )-;
+ qq-( $column $op '' )-;
} else {
- qq-( $_ $op "" )-;
+ qq-( $column $op "" )-;
}
}
} else {
- "$_ $op ?";
+ "$column $op ?";
}
} @fields );
}
$self->getfield($field) =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/
or return "Illegal (IP address) $field: ". $self->getfield($field);
for ( $1, $2, $3, $4 ) { return "Illegal (IP address) $field" if $_ > 255; }
- $self->setfield($field, "$1.$2.$3.$3");
+ $self->setfield($field, "$1.$2.$3.$4");
'';
}