X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=C4%2FSQLHelper.pm;h=b8670942c50478651f63b018c1d9320cfc964fb7;hb=5d6c092921919526ade501facb1220f8a108a08f;hp=e1cb5d0a9aa35e8787d95e867c69077184d2a87f;hpb=5baff558a53fabb7b719bf627064cf2c1680f246;p=koha_fer diff --git a/C4/SQLHelper.pm b/C4/SQLHelper.pm index e1cb5d0a9a..b8670942c5 100644 --- a/C4/SQLHelper.pm +++ b/C4/SQLHelper.pm @@ -46,7 +46,7 @@ eval { BEGIN { # set the version for version checking - $VERSION = 0.5; + $VERSION = 3.07.00.049; require Exporter; @ISA = qw(Exporter); @EXPORT_OK=qw( @@ -248,7 +248,7 @@ Get the Primary Key field names of the table =cut -sub GetPrimaryKeys($) { +sub GetPrimaryKeys { my $tablename=shift; my $hash_columns=_get_columns($tablename); return grep { $hash_columns->{$_}->{'Key'} =~/PRI/i} keys %$hash_columns; @@ -284,7 +284,7 @@ With =cut -sub _get_columns($) { +sub _get_columns { my ($tablename) = @_; unless ( exists( $hashref->{$tablename} ) ) { my $dbh = C4::Context->dbh; @@ -314,7 +314,7 @@ If it is not for research purpose, filter primary keys =cut -sub _filter_columns ($$;$) { +sub _filter_columns { my ($tablename,$research, $filtercolumns)=@_; if ($filtercolumns){ return (@$filtercolumns); @@ -404,9 +404,15 @@ sub _filter_hash{ my $elements=join "|",@columns_filtered; foreach my $field (grep {/\b($elements)\b/} keys %$filter_input){ ## supposed to be a hash of simple values, hashes of arrays could be implemented - $filter_input->{$field}=format_date_in_iso($filter_input->{$field}) - if $columns->{$field}{Type}=~/date/ && - $filter_input->{$field} !~C4::Dates->regexp("iso"); + if ( $columns->{$field}{Type}=~/date/ ) { + if ( defined $filter_input->{$field} ) { + if ( $filter_input->{$field} eq q{} ) { + $filter_input->{$field} = undef; + } elsif ( $filter_input->{$field} !~ C4::Dates->regexp("iso") ) { + $filter_input->{$field} = format_date_in_iso($filter_input->{$field}); + } + } + } my ($tmpkeys, $localvalues)=_Process_Operands($filter_input->{$field},"$tablename.$field",$searchtype,$columns); if (@$tmpkeys){ push @values, @$localvalues;