[Dbix-class] Statement handle does not get finish'ed when select_single.

Jesper Krogh jesper at krogh.cc
Sat Jan 28 10:45:05 CET 2006


I'm not 100% sure that this is a bug in DBIx::Class or a bug in
DBD::JDBC. But this patch doesn't harm any of the modules.

The DBI trows an error upon destruction of a non-empty statement handle
in DDB::JDBC, allthough it doesn't do that in DBD::Pg or DBD::mysql.

Index: lib/DBIx/Class/Storage/DBI.pm
===================================================================
--- lib/DBIx/Class/Storage/DBI.pm       (revision 732)
+++ lib/DBIx/Class/Storage/DBI.pm       (working copy)
@@ -331,10 +331,16 @@
   return $self->cursor->new($self, \@_, $attrs);
 }

+# Cursor calls finish() on the statement handle, when the
+# resultset is several rows. When there is no cursor, we need
+# to call finish here.
+
 sub select_single {
   my $self = shift;
   my ($rv, $sth, @bind) = $self->_select(@_);
-  return $sth->fetchrow_array;
+  my @row = $sth->fetchrow_array;
+  $sth->finish();
+  return @row;
 }

 sub sth {

-- 
Jesper Krogh, jesper at krogh.cc




More information about the Dbix-class mailing list