Skip Menu |

This queue is for tickets about the Class-DBI-Plugin-CountSearch CPAN distribution.

Report information
The Basics
Id: 17933
Status: new
Priority: 0/
Queue: Class-DBI-Plugin-CountSearch

People
Owner: Nobody in particular
Requestors: djh [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.02
Fixed in: (no value)



Subject: broken for NULL values
When I try to execute a statement like: my $count = QD1::Identifier->count_search( coord_id => 1, primary => undef, ); it fails with the message: DBD::mysql::st execute failed: called with 2 bind variables when 1 are needed [for Statement "SELECT COUNT(*) FROM identifiers WHERE coord_id = ? AND primary_id IS NULL because although CDBI-P-CS correctly recognizes the undef, it still passes it to the database. The following patch corrects the problem: --- Class/DBI/Plugin/CountSearch-1.02.pm +++ Class/DBI/Plugin/CountSearch.pm @@ -81,6 +81,8 @@ defined($frag) && $frag ne '' and $frag = " WHERE $frag"; + @vals = grep { defined $_ } @vals; + return $class->sql_count_search($frag)->select_val(@vals); };