EPrints Technical Mailing List Archive
See the EPrints wiki for instructions on how to join this mailing list and related information.
Message: #00800
< Previous (by date) | Next (by date) > | < Previous (in thread) | Next (in thread) > | Messages - Most Recent First | Threads - Most Recent First
[EP-tech] Patch: handle NULL values in EPrints::Search::Condition::Comparison
- To: eprints-tech@ecs.soton.ac.uk
- Subject: [EP-tech] Patch: handle NULL values in EPrints::Search::Condition::Comparison
- From: "Alexander 'Leo' Bergolth" <leo@strike.wu.ac.at>
- Date: Tue, 26 Jun 2012 18:44:37 +0200
Hi! The attached patch changes SQL output to use "IS" instead of "=" when comparing for equality against undefined values. This fixes a problem (at least with Oracle databases) when using views to browse by creators that have an empty givenname. (The SQL that was created contained something like "EPRINT_CREATORS_NAME"."CREATORS_NAME_GIVEN" = NULL ... which will never match. I believe it could also correct several other problems concerning empty fields, however, I did only stumble across the browse view issue yet. Cheers, --leo -- e-mail ::: Leo.Bergolth (at) wu.ac.at fax ::: +43-1-31336-906050 location ::: IT-Services | Vienna University of Economics | Austria
Index: perl_lib/EPrints/Search/Condition/Comparison.pm =================================================================== --- perl_lib/EPrints/Search/Condition/Comparison.pm (revision 5890) +++ perl_lib/EPrints/Search/Condition/Comparison.pm (working copy) @@ -174,9 +174,10 @@ my @logic; for(qw( given family )) { + my $op = ( $self->{op} eq '=' and !defined $self->{params}->[0]->{$_} ) ? 'IS' : $self->{op}; push @logic, sprintf("%s %s %s", $db->quote_identifier( $table, "$sql_name\_$_" ), - $self->{op}, + $op, $db->quote_value( $self->{params}->[0]->{$_} ) ); } return "(".join(") AND (", @logic).")"; @@ -187,16 +188,18 @@ } elsif( $field->isa( "EPrints::MetaField::Int" ) ) { + my $op = ( $self->{op} eq '=' and !defined $self->{params}->[0] ) ? 'IS' : $self->{op}; return sprintf("%s %s %s", $db->quote_identifier( $table, $sql_name ), - $self->{op}, + $op, EPrints::Database::prep_int( $self->{params}->[0] ) ); } else { + my $op = ( $self->{op} eq '=' and !defined $self->{params}->[0] ) ? 'IS' : $self->{op}; return sprintf("%s %s %s", $db->quote_identifier( $table, $sql_name ), - $self->{op}, + $op, $db->quote_value( $self->{params}->[0] ) ); } }
- Follow-Ups:
- [EP-tech] Re: Patch: handle NULL values in EPrints::Search::Condition::Comparison
- From: Tim Brody <tdb2@ecs.soton.ac.uk>
- [EP-tech] Re: Patch: handle NULL values in EPrints::Search::Condition::Comparison
- Prev by Date: [EP-tech] Patch: improve rendering names with empty givenname
- Next by Date: [EP-tech] Patch for EPScript doc_size() and human_filesize() functions (3.2)
- Previous by thread: [EP-tech] Patch: improve rendering names with empty givenname
- Next by thread: [EP-tech] Re: Patch: handle NULL values in EPrints::Search::Condition::Comparison
- Index(es):