[CDBI] Class::DBI and DBD::Mock problem

Aaron Trevena aaron.trevena at gmail.com
Tue Mar 20 15:14:53 GMT 2007


Hey you crazy kids,

I'm trying to unit test some hairy query autogeneration using Traits
and Class::DBI - the obvious thing to do is to use DBD::Mock and
populate some fake results, and check the params and statement
provided.

Unfortunately I get the following error when using DBD::Mock in place
of a real driver :

DBI bind_columns: invalid number of arguments: got handle + 0,
expected handle + between 1 and -1
Usage: $h->bind_columns(\$var1 [, \$var2, ...]) at
/usr/lib/perl5/site_perl/5.8.5/Class/DBI.pm line 1140.

when calling sth_to_objects, which I've over-ridden to do :

sub sth_to_objects {
  my ($self,$sth) = (shift, at _);
  # get mockdbi info
  warn "over-ridden sth_to_objects called with...\n";
  warn Dumper(@_);

  $self->{__test}{mock_params} = $sth->{mock_params};
  $self->{__test}{mock_statement} =  $sth->{mock_statement};

  warn "params : ", @{$sth->{mock_params}}, "\n";
  warn "statement : ", $sth->{mock_statement}, "\n";

  return $self->SUPER::sth_to_objects(@_);
}

Any suggestions of how to make this work or how to bug fix either CDBI
or DBD::Mock much appreciated.

ta muchly,

A.

-- 
http://www.aarontrevena.co.uk
LAMP System Integration, Development and Hosting



More information about the ClassDBI mailing list